File tree 4 files changed +24
-5
lines changed
compiler/src/dotty/tools/dotc 4 files changed +24
-5
lines changed Original file line number Diff line number Diff line change @@ -1467,7 +1467,11 @@ object SymDenotations {
1467
1467
onBehalf.signalProvisional()
1468
1468
val builder = new BaseDataBuilder
1469
1469
for (p <- classParents) {
1470
- p.underlyingClassRef(refinementOK = false ).typeSymbol match {
1470
+ var pcls = p.typeSymbol
1471
+ if (! pcls.isClass) pcls = p.underlyingClassRef(refinementOK = false ).typeSymbol
1472
+ // This roundabout way is necessary for avoiding cyclic references.
1473
+ // A test case is CompilationTests.compileMixed
1474
+ pcls match {
1471
1475
case pcls : ClassSymbol => builder.addAll(pcls.baseClasses)
1472
1476
case _ => assert(isRefinementClass || ctx.mode.is(Mode .Interactive ), s " $this has non-class parent: $p" )
1473
1477
}
Original file line number Diff line number Diff line change @@ -164,8 +164,11 @@ object NamerContextOps {
164
164
/** Find moduleClass/sourceModule in effective scope */
165
165
private def findModuleBuddy (name : Name , scope : Scope )(implicit ctx : Context ) = {
166
166
val it = scope.lookupAll(name).filter(_ is Module )
167
- assert(it.hasNext, s " no companion $name in $scope" )
168
- it.next()
167
+ if (it.hasNext) it.next()
168
+ else {
169
+ assert(ctx.reporter.errorsReported, s " no companion $name in $scope" )
170
+ NoSymbol
171
+ }
169
172
}
170
173
}
171
174
@@ -1033,8 +1036,11 @@ class Namer { typer: Typer =>
1033
1036
*/
1034
1037
def moduleValSig (sym : Symbol )(implicit ctx : Context ): Type = {
1035
1038
val clsName = sym.name.moduleClassName
1036
- val cls = ctx.denotNamed(clsName) suchThat (_ is ModuleClass )
1037
- ctx.owner.thisType select (clsName, cls)
1039
+ val cls = ctx.denotNamed(clsName).suchThat(_ is ModuleClass ).orElse {
1040
+ assert(ctx.reporter.errorsReported)
1041
+ ctx.newStubSymbol(ctx.owner, clsName)
1042
+ }
1043
+ ctx.owner.thisType.select(clsName, cls)
1038
1044
}
1039
1045
1040
1046
/** The type signature of a ValDef or DefDef
Original file line number Diff line number Diff line change
1
+ object x0 {
2
+ {
3
+ val x1 x0 // error
4
+ object x1 // error // error
Original file line number Diff line number Diff line change
1
+ class x0 [x0] {
2
+ val x1 : x0
3
+ }
4
+ trait x3 extends x0 {
5
+ x1 = 0 object // error // error
You can’t perform that action at this time.
0 commit comments