Skip to content

Fix #6460: less forcing in checkNonCyclic #6493

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 2 commits into from
May 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/Denotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1301,12 +1301,12 @@ object Denotations {
if (owner.exists) {
val result = if (isPackage) owner.info.decl(selector) else owner.info.member(selector)
if (result.exists) result
else if (isPackageFromCoreLibMissing) throw new MissingCoreLibraryException(selector.toString)
else {
val alt =
if (generateStubs) missingHook(owner.symbol.moduleClass, selector)
else NoSymbol
if (alt.exists) alt.denot
else if (isPackageFromCoreLibMissing) throw new MissingCoreLibraryException(selector.toString)
else MissingRef(owner, selector)
}
}
Expand Down
41 changes: 27 additions & 14 deletions compiler/src/dotty/tools/dotc/core/SymDenotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,9 @@ object SymDenotations {
* During completion, references to moduleClass and sourceModules are stored in
* the completers.
*/
/** The class implementing this module, NoSymbol if not applicable. */
/** If this a module, return the corresponding class, if this is a module, return itself,
* otherwise NoSymbol
*/
final def moduleClass(implicit ctx: Context): Symbol = {
def notFound = {
if (Config.showCompletions) println(s"missing module class for $name: $myInfo")
Expand All @@ -870,23 +872,34 @@ object SymDenotations {
}
case _ => notFound
}
else NoSymbol
else if (this is ModuleClass)
symbol
else
NoSymbol
}

/** The module implemented by this module class, NoSymbol if not applicable. */
final def sourceModule(implicit ctx: Context): Symbol = myInfo match {
case ClassInfo(_, _, _, _, selfType) if this is ModuleClass =>
def sourceOfSelf(tp: TypeOrSymbol): Symbol = tp match {
case tp: TermRef => tp.symbol
case tp: Symbol => sourceOfSelf(tp.info)
case tp: RefinedType => sourceOfSelf(tp.parent)
/** If this a module class, return the corresponding module, if this is a module, return itself,
* otherwise NoSymbol
*/
final def sourceModule(implicit ctx: Context): Symbol =
if (this is ModuleClass)
myInfo match {
case ClassInfo(_, _, _, _, selfType) =>
def sourceOfSelf(tp: TypeOrSymbol): Symbol = tp match {
case tp: TermRef => tp.symbol
case tp: Symbol => sourceOfSelf(tp.info)
case tp: RefinedType => sourceOfSelf(tp.parent)
}
sourceOfSelf(selfType)
case info: LazyType =>
info.sourceModule
case _ =>
NoSymbol
}
sourceOfSelf(selfType)
case info: LazyType =>
info.sourceModule
case _ =>
else if (this is ModuleVal)
symbol
else
NoSymbol
}

/** The field accessed by this getter or setter, or if it does not exist, the getter */
def accessedFieldOrGetter(implicit ctx: Context): Symbol = {
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/interactive/Completion.scala
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ object Completion {
!sym.isAbsent &&
!sym.isPrimaryConstructor &&
sym.sourceSymbol.exists &&
(!sym.is(Package) || !sym.moduleClass.exists) &&
(!sym.is(Package) || sym.is(ModuleClass)) &&
!sym.is(allOf(Mutable, Accessor)) &&
!sym.isPackageObject &&
!sym.is(Artifact) &&
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/typer/Checking.scala
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ object Checking {
)
case prefix: NamedType =>
(!sym.is(Private) && prefix.derivesFrom(sym.owner)) ||
(!prefix.symbol.isStaticOwner && isInteresting(prefix.prefix))
(!prefix.symbol.moduleClass.isStaticOwner && isInteresting(prefix.prefix))
case SuperType(thistp, _) => isInteresting(thistp)
case AndType(tp1, tp2) => isInteresting(tp1) || isInteresting(tp2)
case OrType(tp1, tp2) => isInteresting(tp1) && isInteresting(tp2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,15 @@ class BootstrappedOnlyCompilationTests extends ParallelTesting {
compileDir("compiler/src/dotty/tools/dotc/reporting", withCompilerOptions),
compileDir("compiler/src/dotty/tools/dotc/typer", withCompilerOptions),
compileDir("compiler/src/dotty/tools/dotc/util", withCompilerOptions),
compileDir("compiler/src/dotty/tools/io", withCompilerOptions)
compileDir("compiler/src/dotty/tools/io", withCompilerOptions),
compileList(
"testIssue6460",
List(
"compiler/src/dotty/tools/dotc/core/SymbolLoaders.scala",
"compiler/src/dotty/tools/dotc/core/Types.scala"
),
withCompilerOptions
),
).checkCompile()
}

Expand Down
2 changes: 1 addition & 1 deletion tests/neg/toplevel-cyclic/defs_1.scala
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
type A = B // error: illegal cyclic reference
type A = B // error: recursion limit exceeded

2 changes: 1 addition & 1 deletion tests/neg/toplevel-cyclic/moredefs_1.scala
Original file line number Diff line number Diff line change
@@ -1 +1 @@
type B = A
type B = A // error: recursion limit exceeded // error: recursion limit exceeded