File tree 3 files changed +19
-5
lines changed
compiler/src/dotty/tools/dotc
3 files changed +19
-5
lines changed Original file line number Diff line number Diff line change @@ -45,9 +45,13 @@ trait SymDenotations { this: Context =>
45
45
else {
46
46
val initial = denot.initial
47
47
val firstPhaseId = initial.validFor.firstPhaseId.max(ctx.typerPhase.id)
48
- if ((initial ne denot) || ctx.phaseId != firstPhaseId)
49
- ctx.withPhase(firstPhaseId).stillValidInOwner(initial)
50
- else
48
+ if ((initial ne denot) || ctx.phaseId != firstPhaseId) {
49
+ ctx.withPhase(firstPhaseId).stillValidInOwner(initial) ||
50
+ // Workaround #1895: A symbol might not be entered into an owner
51
+ // until the second phase where it exists
52
+ (denot.validFor.containsPhaseId(firstPhaseId + 1 )) &&
53
+ ctx.withPhase(firstPhaseId + 1 ).stillValidInOwner(initial)
54
+ } else
51
55
stillValidInOwner(denot)
52
56
}
53
57
Original file line number Diff line number Diff line change @@ -63,8 +63,13 @@ class ExtensionMethods extends MiniPhaseTransform with DenotTransformer with Ful
63
63
// not generate them again.
64
64
if (! (valueClass is Scala2x )) ctx.atPhase(thisTransformer) { implicit ctx =>
65
65
for (decl <- valueClass.classInfo.decls) {
66
- if (isMethodWithExtension(decl))
67
- decls1.enter(createExtensionMethod(decl, moduleClassSym.symbol))
66
+ if (isMethodWithExtension(decl)) {
67
+ val meth = createExtensionMethod(decl, moduleClassSym.symbol)
68
+ decls1.enter(meth)
69
+ // Workaround #1895: force denotation of `meth` to be
70
+ // at phase where `meth` is entered into the decls of a class
71
+ meth.denot(ctx.withPhase(thisTransformer.next))
72
+ }
68
73
}
69
74
}
70
75
Original file line number Diff line number Diff line change
1
+ scala> class Foo(x: Int) extends AnyVal { def hi: Int = 1 }
2
+ defined class Foo
3
+ scala> new Foo(1).hi
4
+ val res0: Int = 1
5
+ scala> :quit
You can’t perform that action at this time.
0 commit comments