Skip to content

Fix more problems detected by fuzzing in #4389 #4411

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Apr 30, 2018
Merged
13 changes: 4 additions & 9 deletions compiler/src/dotty/tools/dotc/core/SymDenotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1466,16 +1466,11 @@ object SymDenotations {
if (classParents.isEmpty && !emptyParentsExpected)
onBehalf.signalProvisional()
val builder = new BaseDataBuilder
for (p <- classParents) {
var pcls = p.typeSymbol
if (!pcls.isClass) pcls = p.underlyingClassRef(refinementOK = false).typeSymbol
// This roundabout way is necessary for avoiding cyclic references.
// A test case is CompilationTests.compileMixed
pcls match {
for (p <- classParents)
p.classSymbol match {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

incorrect indentation.

case pcls: ClassSymbol => builder.addAll(pcls.baseClasses)
case _ => assert(isRefinementClass || ctx.mode.is(Mode.Interactive), s"$this has non-class parent: $p")
}
}
(classSymbol :: builder.baseClasses, builder.baseClassSet)
}

Expand Down Expand Up @@ -1604,7 +1599,7 @@ object SymDenotations {
def collect(denots: PreDenotation, parents: List[Type]): PreDenotation = parents match {
case p :: ps =>
val denots1 = collect(denots, ps)
p.typeSymbol.denot match {
p.classSymbol.denot match {
case parentd: ClassDenotation =>
denots1 union
parentd.nonPrivateMembersNamed(name)
Expand Down Expand Up @@ -1753,7 +1748,7 @@ object SymDenotations {
var names = Set[Name]()
def maybeAdd(name: Name) = if (keepOnly(thisType, name)) names += name
for (p <- classParents)
for (name <- p.typeSymbol.asClass.memberNames(keepOnly))
for (name <- p.classSymbol.asClass.memberNames(keepOnly))
maybeAdd(name)
val ownSyms =
if (keepOnly eq implicitFilter)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class CheckReentrant extends MiniPhase {
}
}
for (parent <- cls.classInfo.classParents)
addVars(parent.typeSymbol.asClass)
addVars(parent.classSymbol.asClass)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ object GenericSignatures {
val validParents =
if (isTraitSignature)
// java is unthrilled about seeing interfaces inherit from classes
minParents filter (p => isInterfaceOrTrait(p.typeSymbol))
minParents filter (p => isInterfaceOrTrait(p.classSymbol))
else minParents

val ps = ensureClassAsFirstParent(validParents)
Expand Down Expand Up @@ -329,11 +329,11 @@ object GenericSignatures {
def isUnshadowed(psym: Symbol) =
!(psyms exists (qsym => (psym ne qsym) && (qsym isSubClass psym)))
val cs = parents.iterator.filter { p => // isUnshadowed is a bit expensive, so try classes first
val psym = p.typeSymbol
val psym = p.classSymbol
psym.ensureCompleted()
psym.isClass && !psym.is(Trait) && isUnshadowed(psym)
}
(if (cs.hasNext) cs else parents.iterator.filter(p => isUnshadowed(p.typeSymbol))).next()
(if (cs.hasNext) cs else parents.iterator.filter(p => isUnshadowed(p.classSymbol))).next()
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/typer/Implicits.scala
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ trait ImplicitRunInfo { self: Run =>
comps += companion.asSeenFrom(pre, compSym.owner).asInstanceOf[TermRef]
}
def addParentScope(parent: Type): Unit =
iscopeRefs(tp.baseType(parent.typeSymbol)) foreach addRef
iscopeRefs(tp.baseType(parent.classSymbol)) foreach addRef
val companion = cls.companionModule
if (companion.exists) addRef(companion.termRef)
cls.classParents foreach addParentScope
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/typer/RefChecks.scala
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ object RefChecks {
cls.pos)
}
for (parent <- cinfo.classParents)
checkSelfConforms(parent.typeSymbol.asClass, "illegal inheritance", "parent")
checkSelfConforms(parent.classSymbol.asClass, "illegal inheritance", "parent")
for (reqd <- cinfo.cls.givenSelfType.classSymbols)
checkSelfConforms(reqd, "missing requirement", "required")
case _ =>
Expand Down
2 changes: 2 additions & 0 deletions tests/neg/parser-stability-21.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class x0[x1[]] // error
extends x1[ // error // error