Skip to content
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

Compiler crashes with cyclic type deferencing error #7778

Closed
scabug opened this issue Aug 23, 2013 · 5 comments
Closed

Compiler crashes with cyclic type deferencing error #7778

scabug opened this issue Aug 23, 2013 · 5 comments
Labels

Comments

@scabug
Copy link

@scabug scabug commented Aug 23, 2013

I am using Spring Security in a Scala project. The following code causes the Scala compiler to crash with a cyclic type dereferencing error. An equivalent Java code compiles just fine. I tried using 2.10.2, 2.10.3-RC1, and 2.11.0.M4; all crashed in an identical manner. I get the same crash in Scala IDE (latest nightly) as well.

package com.example.cyclic_type

import org.springframework.security.config.annotation.web.builders.HttpSecurity

class SecurityConfig {
  def configure(http: HttpSecurity) {
    // commenting the following line stops compiler from crashing
    http.authorizeRequests()
  }
}

See the attached simplest code that I can get to crash (just do 'sbt compile' to reproduce the crash). SecurityConfigJava that is equivalent to the Scala class is also included.

The crash:

[error] 
[error]   last tree to typer: Ident(http)
[error]               symbol: value http (flags: <param> <triedcooking>)
[error]    symbol definition: http: org.springframework.security.config.annotation.web.builders.HttpSecurity
[error]                  tpe: http.type
[error]        symbol owners: value http -> method configure -> class SecurityConfig -> package cyclic_type
[error]       context owners: method configure -> class SecurityConfig -> package cyclic_type
[error] 
[error] == Enclosing template or block ==
[error] 
[error] DefDef( // override def configure(http: org.springframework.security.config.annotation.web.builders.HttpSecurity): Unit in class SecurityConfig
[error]   <method> override
[error]   "configure"
[error]   []
[error]   // 1 parameter list
[error]   ValDef( // http: org.springframework.security.config.annotation.web.builders.HttpSecurity
[error]     <param> <triedcooking>
[error]     "http"
[error]     "HttpSecurity"
[error]     <empty>
[error]   )
[error]   "scala"."Unit" // final abstract class Unit extends AnyVal in package scala, tree.tpe=Unit
[error]   Apply( // def authorizeRequests(): org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer[org.springframework.security.config.annotation.web.builders.HttpSecurity] in class HttpSecurity, tree.tpe=org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer[org.springframework.security.config.annotation.web.builders.HttpSecurity]
[error]     "http"."authorizeRequests" // def authorizeRequests(): org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer[org.springframework.security.config.annotation.web.builders.HttpSecurity] in class HttpSecurity, tree.tpe=()org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer[org.springframework.security.config.annotation.web.builders.HttpSecurity]
[error]     Nil
[error]   )
[error] )
[error] 
[error] == Expanded type of tree ==
[error] 
[error] SingleType(value http)
[error] 
[error] uncaught exception during compilation: java.lang.AssertionError
java.lang.AssertionError: cyclic type dereferencing
	at scala.tools.nsc.symtab.classfile.ClassfileParser$TypeParamsType.complete(ClassfileParser.scala:847)
	at scala.reflect.internal.Symbols$Symbol.info(Symbols.scala:1229)
	at scala.reflect.internal.Types$TypeRef.thisInfo(Types.scala:2407)
	at scala.reflect.internal.Types$TypeRef.baseClasses(Types.scala:2412)
	at scala.reflect.internal.Types$Type.findMember(Types.scala:1173)
	at scala.reflect.internal.Types$Type.memberBasedOnName(Types.scala:722)
	at scala.reflect.internal.Types$Type.member(Types.scala:680)
	at scala.tools.nsc.symtab.classfile.ClassfileParser.sig2type$1(ClassfileParser.scala:757)
	at scala.tools.nsc.symtab.classfile.ClassfileParser.processClassType$1(ClassfileParser.scala:732)
	at scala.tools.nsc.symtab.classfile.ClassfileParser.sig2type$1(ClassfileParser.scala:753)
	at scala.tools.nsc.symtab.classfile.ClassfileParser.scala$tools$nsc$symtab$classfile$ClassfileParser$$sigToType(ClassfileParser.scala:839)
	at scala.tools.nsc.symtab.classfile.ClassfileParser.scala$tools$nsc$symtab$classfile$ClassfileParser$$parseAttribute$1(ClassfileParser.scala:864)
	at scala.tools.nsc.symtab.classfile.ClassfileParser.parseAttributes(ClassfileParser.scala:1080)
	at scala.tools.nsc.symtab.classfile.ClassfileParser.parseClass(ClassfileParser.scala:551)
	at scala.tools.nsc.symtab.classfile.ClassfileParser.parse(ClassfileParser.scala:90)
	at scala.tools.nsc.symtab.SymbolLoaders$ClassfileLoader.doComplete(SymbolLoaders.scala:261)
	at scala.tools.nsc.symtab.SymbolLoaders$SymbolLoader.complete(SymbolLoaders.scala:194)
	at scala.reflect.internal.Symbols$Symbol.info(Symbols.scala:1229)
	at scala.reflect.internal.Types$ClassTypeRef$class.baseType(Types.scala:2186)
	at scala.reflect.internal.Types$TypeRef$$anon$5.baseType(Types.scala:2536)
	at scala.reflect.internal.Types$class.firstTry$1(Types.scala:6059)
	at scala.reflect.internal.Types$class.isSubType2(Types.scala:6223)
	at scala.reflect.internal.Types$class.isSubType(Types.scala:5832)
	at scala.reflect.internal.SymbolTable.isSubType(SymbolTable.scala:13)
	at scala.reflect.internal.Types$Type.$less$colon$less(Types.scala:872)
	at scala.tools.nsc.typechecker.Typers$Typer.adapt(Typers.scala:1159)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5626)
	at scala.tools.nsc.typechecker.Typers$Typer.transformedOrTyped(Typers.scala:5811)
	at scala.tools.nsc.typechecker.Typers$Typer.typedDefDef(Typers.scala:2256)
	at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5535)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5608)
	at scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$typedStat$1(Typers.scala:2927)
	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$60.apply(Typers.scala:3031)
	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$60.apply(Typers.scala:3031)
	at scala.collection.immutable.List.loop$1(List.scala:170)
	at scala.collection.immutable.List.mapConserve(List.scala:186)
	at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:3031)
	at scala.tools.nsc.typechecker.Typers$Typer.typedTemplate(Typers.scala:1918)
	at scala.tools.nsc.typechecker.Typers$Typer.typedClassDef(Typers.scala:1758)
	at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5549)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5608)
	at scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$typedStat$1(Typers.scala:2927)
	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$60.apply(Typers.scala:3031)
	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$60.apply(Typers.scala:3031)
	at scala.collection.immutable.List.loop$1(List.scala:170)
	at scala.collection.immutable.List.mapConserve(List.scala:186)
	at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:3031)
	at scala.tools.nsc.typechecker.Typers$Typer.typedPackageDef$1(Typers.scala:5267)
	at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5553)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5608)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5670)
	at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3.apply(Analyzer.scala:99)
	at scala.tools.nsc.Global$GlobalPhase.applyPhase(Global.scala:464)
	at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3$$anonfun$run$1.apply(Analyzer.scala:91)
	at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3$$anonfun$run$1.apply(Analyzer.scala:91)
	at scala.collection.Iterator$class.foreach(Iterator.scala:727)
	at scala.collection.AbstractIterator.foreach(Iterator.scala:1157)
	at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3.run(Analyzer.scala:91)
	at scala.tools.nsc.Global$Run.compileUnitsInternal(Global.scala:1583)
	at scala.tools.nsc.Global$Run.compileUnits(Global.scala:1557)
	at scala.tools.nsc.Global$Run.compileSources(Global.scala:1553)
	at scala.tools.nsc.Global$Run.compile(Global.scala:1662)
	at xsbt.CachedCompiler0.run(CompilerInterface.scala:90)
	at xsbt.CachedCompiler0.run(CompilerInterface.scala:72)
	at xsbt.CompilerInterface.run(CompilerInterface.scala:26)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:601)
	at sbt.compiler.AnalyzingCompiler.call(AnalyzingCompiler.scala:73)
	at sbt.compiler.AnalyzingCompiler.compile(AnalyzingCompiler.scala:35)
	at sbt.compiler.AnalyzingCompiler.compile(AnalyzingCompiler.scala:29)
	at sbt.compiler.AggressiveCompile$$anonfun$4$$anonfun$compileScala$1$1.apply$mcV$sp(AggressiveCompile.scala:71)
	at sbt.compiler.AggressiveCompile$$anonfun$4$$anonfun$compileScala$1$1.apply(AggressiveCompile.scala:71)
	at sbt.compiler.AggressiveCompile$$anonfun$4$$anonfun$compileScala$1$1.apply(AggressiveCompile.scala:71)
	at sbt.compiler.AggressiveCompile.sbt$compiler$AggressiveCompile$$timed(AggressiveCompile.scala:101)
	at sbt.compiler.AggressiveCompile$$anonfun$4.compileScala$1(AggressiveCompile.scala:70)
	at sbt.compiler.AggressiveCompile$$anonfun$4.apply(AggressiveCompile.scala:88)
	at sbt.compiler.AggressiveCompile$$anonfun$4.apply(AggressiveCompile.scala:60)
	at sbt.inc.IncrementalCompile$$anonfun$doCompile$1.apply(Compile.scala:24)
	at sbt.inc.IncrementalCompile$$anonfun$doCompile$1.apply(Compile.scala:22)
	at sbt.inc.Incremental$.cycle(Incremental.scala:39)
	at sbt.inc.Incremental$.compile(Incremental.scala:26)
	at sbt.inc.IncrementalCompile$.apply(Compile.scala:20)
	at sbt.compiler.AggressiveCompile.compile2(AggressiveCompile.scala:96)
	at sbt.compiler.AggressiveCompile.compile1(AggressiveCompile.scala:44)
	at sbt.compiler.AggressiveCompile.apply(AggressiveCompile.scala:31)
	at sbt.Compiler$.apply(Compiler.scala:79)
	at sbt.Defaults$$anonfun$compileTask$1.apply(Defaults.scala:571)
	at sbt.Defaults$$anonfun$compileTask$1.apply(Defaults.scala:571)
	at sbt.Scoped$$anonfun$hf2$1.apply(Structure.scala:578)
	at sbt.Scoped$$anonfun$hf2$1.apply(Structure.scala:578)
	at scala.Function1$$anonfun$compose$1.apply(Function1.scala:49)
	at sbt.Scoped$Reduced$$anonfun$combine$1$$anonfun$apply$12.apply(Structure.scala:311)
	at sbt.Scoped$Reduced$$anonfun$combine$1$$anonfun$apply$12.apply(Structure.scala:311)
	at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:40)
	at sbt.std.Transform$$anon$5.work(System.scala:71)
	at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:232)
	at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:232)
	at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:18)
	at sbt.Execute.work(Execute.scala:238)
	at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:232)
	at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:232)
	at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:159)
	at sbt.CompletionService$$anon$2.call(CompletionService.scala:30)
	at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
	at java.util.concurrent.FutureTask.run(FutureTask.java:166)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
	at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
	at java.util.concurrent.FutureTask.run(FutureTask.java:166)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at java.lang.Thread.run(Thread.java:722)
[error] (compile:compile) java.lang.AssertionError: cyclic type dereferencing
@scabug
Copy link
Author

@scabug scabug commented Aug 23, 2013

Imported From: https://issues.scala-lang.org/browse/SI-7778?orig=1
Reporter: Ramnivas Laddad (ramnivas)
Affected Versions: 2.10.2, 2.10.3-RC1, 2.11.0-M4
See #942
Attachments:

  • cyclic.zip (created on Aug 23, 2013 12:36:25 AM UTC, 2328 bytes)

@scabug
Copy link
Author

@scabug scabug commented Aug 23, 2013

@retronym said:
Minimized:

import java.util.concurrent.Callable;

public abstract class Foo<T> implements Callable<Foo<Object>.Inner> {
    public abstract class Inner {
    }
}
class Test {
  null: Foo[_]
}

@scabug
Copy link
Author

@scabug scabug commented Aug 23, 2013

@retronym said:
The lazy type: TypeParamsType that trips the assertion was added in 47f35b58, which fixed #942.

@scabug
Copy link
Author

@scabug scabug commented Aug 23, 2013

@retronym said:
Adding a test for #942 and a pending test for this bug: scala/scala#2870

@scabug scabug added the backend label Apr 7, 2017
@SethTisue
Copy link
Member

@SethTisue SethTisue commented Mar 1, 2018

closing backend tickets which are likely stale; comment and/or reopen if you have evidence this is still applicable

@SethTisue SethTisue closed this Mar 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants