Skip to content

Types refined with terms cannot be refined further #214

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

Closed
smarter opened this issue Nov 4, 2014 · 2 comments
Closed

Types refined with terms cannot be refined further #214

smarter opened this issue Nov 4, 2014 · 2 comments

Comments

@smarter
Copy link
Member

smarter commented Nov 4, 2014

The following code:

object Test {
  type F = { val x: Int }
  type G = F {}
}

makes dotty throw an exception because normalizeToRef does not handle parents which are RefinedType where the refinement is a term and not a type:

[error] Exception in thread "main" dotty.tools.dotc.core.Types$TypeError: unexpected parent type: RefinedType(TypeRef(ThisType(TypeRef(NoPrefix,lang)),Object), x, TypeRef(TermRef(ThisType(TypeRef(NoPrefix,<root>)),scala),Int))
[error]         at dotty.tools.dotc.core.TypeOps$class.normalizeToRef$1(TypeOps.scala:286)
[error]         at dotty.tools.dotc.core.TypeOps$$anonfun$5.apply(TypeOps.scala:288)
[error]         at dotty.tools.dotc.core.TypeOps$$anonfun$5.apply(TypeOps.scala:288)
[error]         at scala.collection.immutable.List.map(List.scala:274)
[error]         at dotty.tools.dotc.core.TypeOps$class.normalizeToClassRefs(TypeOps.scala:288)
[error]         at dotty.tools.dotc.core.Contexts$Context.normalizeToClassRefs(Contexts.scala:51)
[error]         at dotty.tools.dotc.typer.Namer$ClassCompleter.completeInCreationContext(Namer.scala:489)
[error]         at dotty.tools.dotc.typer.Namer$Completer.complete(Namer.scala:424)
[error]         at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:151)
[error]         at dotty.tools.dotc.core.SymDenotations$SymDenotation.info(SymDenotations.scala:133)
[error]         at dotty.tools.dotc.core.SymDenotations$SymDenotation.ensureCompleted(SymDenotations.scala:234)
[error]         at dotty.tools.dotc.typer.Typer.retrieveSym(Typer.scala:920)
[error]         at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:945)
[error]         at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1005)
[error]         at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:1017)
[error]         at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:1015)
[error]         at dotty.tools.dotc.reporting.Reporting$class.traceIndented(Reporter.scala:162)
[error]         at dotty.tools.dotc.core.Contexts$Context.traceIndented(Contexts.scala:51)
[error]         at dotty.tools.dotc.reporting.Reporting$class.traceIndented(Reporter.scala:146)
[error]         at dotty.tools.dotc.core.Contexts$Context.traceIndented(Contexts.scala:51)
[error]         at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1015)
[error]         at dotty.tools.dotc.typer.Typer$$anonfun$typedRefinedTypeTree$1.apply(Typer.scala:732)
[error]         at dotty.tools.dotc.typer.Typer$$anonfun$typedRefinedTypeTree$1.apply(Typer.scala:728)
[error]         at dotty.tools.dotc.util.Stats$.track(Stats.scala:35)
[error]         at dotty.tools.dotc.typer.Typer.typedRefinedTypeTree(Typer.scala:728)
[error]         at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:991)
[error]         at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1007)
[error]         at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:1017)
[error]         at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:1015)
[error]         at dotty.tools.dotc.reporting.Reporting$class.traceIndented(Reporter.scala:162)
[error]         at dotty.tools.dotc.core.Contexts$Context.traceIndented(Contexts.scala:51)
[error]         at dotty.tools.dotc.reporting.Reporting$class.traceIndented(Reporter.scala:146)
[error]         at dotty.tools.dotc.core.Contexts$Context.traceIndented(Contexts.scala:51)
[error]         at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1015)
[error]         at dotty.tools.dotc.typer.Namer.typedAheadImpl(Namer.scala:503)
[error]         at dotty.tools.dotc.typer.Namer.typedAheadType(Namer.scala:510)
[error]         at dotty.tools.dotc.typer.Namer.typeDefSig(Namer.scala:670)
[error]         at dotty.tools.dotc.typer.Namer$Completer.typeSig(Namer.scala:402)
[error]         at dotty.tools.dotc.typer.Namer$Completer.completeInCreationContext(Namer.scala:428)
[error]         at dotty.tools.dotc.typer.Namer$Completer.complete(Namer.scala:424)
[error]         at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:151)
[error]         at dotty.tools.dotc.core.SymDenotations$SymDenotation.info(SymDenotations.scala:133)
[error]         at dotty.tools.dotc.core.SymDenotations$SymDenotation.ensureCompleted(SymDenotations.scala:234)
[error]         at dotty.tools.dotc.typer.Typer.retrieveSym(Typer.scala:920)
[error]         at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:945)
[error]         at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1005)
[error]         at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:1017)
[error]         at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:1015)
[error]         at dotty.tools.dotc.reporting.Reporting$class.traceIndented(Reporter.scala:162)
[error]         at dotty.tools.dotc.core.Contexts$Context.traceIndented(Contexts.scala:51)
[error]         at dotty.tools.dotc.reporting.Reporting$class.traceIndented(Reporter.scala:146)
[error]         at dotty.tools.dotc.core.Contexts$Context.traceIndented(Contexts.scala:51)
[error]         at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1015)
[error]         at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:1039)
[error]         at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:1051)
[error]         at dotty.tools.dotc.typer.Typer$$anonfun$typedClassDef$1.apply(Typer.scala:852)
[error]         at dotty.tools.dotc.typer.Typer$$anonfun$typedClassDef$1.apply(Typer.scala:834)
[error]         at dotty.tools.dotc.util.Stats$.track(Stats.scala:35)
[error]         at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:834)
[error]         at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:959)
[error]         at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1005)
[error]         at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:1017)
[error]         at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:1015)
[error]         at dotty.tools.dotc.reporting.Reporting$class.traceIndented(Reporter.scala:162)
[error]         at dotty.tools.dotc.core.Contexts$Context.traceIndented(Contexts.scala:51)
[error]         at dotty.tools.dotc.reporting.Reporting$class.traceIndented(Reporter.scala:146)
[error]         at dotty.tools.dotc.core.Contexts$Context.traceIndented(Contexts.scala:51)
[error]         at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1015)
[error]         at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:1039)
[error]         at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:1051)
[error]         at dotty.tools.dotc.typer.Typer$$anonfun$typedPackageDef$1.apply(Typer.scala:899)
[error]         at dotty.tools.dotc.typer.Typer$$anonfun$typedPackageDef$1.apply(Typer.scala:890)
[error]         at dotty.tools.dotc.util.Stats$.track(Stats.scala:35)
[error]         at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:890)
[error]         at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:996)
[error]         at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1007)
[error]         at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:1017)
[error]         at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:1015)
[error]         at dotty.tools.dotc.reporting.Reporting$class.traceIndented(Reporter.scala:162)
[error]         at dotty.tools.dotc.core.Contexts$Context.traceIndented(Contexts.scala:51)
[error]         at dotty.tools.dotc.reporting.Reporting$class.traceIndented(Reporter.scala:146)
[error]         at dotty.tools.dotc.core.Contexts$Context.traceIndented(Contexts.scala:51)
[error]         at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1015)
[error]         at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:1055)
[error]         at dotty.tools.dotc.typer.FrontEnd$$anonfun$typeCheck$1.apply$mcV$sp(FrontEnd.scala:37)
[error]         at dotty.tools.dotc.typer.FrontEnd.monitor(FrontEnd.scala:16)
[error]         at dotty.tools.dotc.typer.FrontEnd.typeCheck(FrontEnd.scala:35)
[error]         at dotty.tools.dotc.typer.FrontEnd$$anonfun$runOn$3.apply(FrontEnd.scala:48)
[error]         at dotty.tools.dotc.typer.FrontEnd$$anonfun$runOn$3.apply(FrontEnd.scala:48)
[error]         at scala.collection.immutable.List.foreach(List.scala:383)
[error]         at dotty.tools.dotc.typer.FrontEnd.runOn(FrontEnd.scala:48)
[error]         at dotty.tools.dotc.Run$$anonfun$compileSources$1$$anonfun$apply$mcV$sp$3.apply(Run.scala:49)
[error]         at dotty.tools.dotc.Run$$anonfun$compileSources$1$$anonfun$apply$mcV$sp$3.apply(Run.scala:47)
[error]         at scala.collection.IndexedSeqOptimized$class.foreach(IndexedSeqOptimized.scala:33)
[error]         at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:186)
[error]         at dotty.tools.dotc.Run$$anonfun$compileSources$1.apply$mcV$sp(Run.scala:47)
[error]         at dotty.tools.dotc.Run$$anonfun$compileSources$1.apply(Run.scala:39)
[error]         at dotty.tools.dotc.Run$$anonfun$compileSources$1.apply(Run.scala:39)
[error]         at dotty.tools.dotc.util.Stats$.monitorHeartBeat(Stats.scala:68)
[error]         at dotty.tools.dotc.Run.compileSources(Run.scala:38)
[error]         at dotty.tools.dotc.Run.compile(Run.scala:29)
[error]         at dotty.tools.dotc.Driver.doCompile(Driver.scala:19)
[error]         at dotty.tools.dotc.Main$.doCompile(Main.scala:26)
[error]         at dotty.tools.dotc.Driver.process(Driver.scala:30)
[error]         at dotty.tools.dotc.Driver.main(Driver.scala:44)
[error]         at dotty.tools.dotc.Main.main(Main.scala)

Scalac compiles the code correctly, is this a missing feature in Dotty or are you not supporting these refinements intentionally?
CC @odersky @DarkDimius @namin

@smarter
Copy link
Member Author

smarter commented Nov 6, 2014

Here's a more direct way to trigger the bug, this works:

abstract class A extends { val x: Int }

This explodes:

abstract class A extends ({ val x: Int })

@odersky
Copy link
Contributor

odersky commented Dec 13, 2014

Suplicate of #248

@odersky odersky closed this as completed Dec 13, 2014
WojciechMazur pushed a commit to WojciechMazur/dotty that referenced this issue May 8, 2025
Backport "Fix chocolatey-test when used in stable releases" to 3.3 LTS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants