"Not a simple type" warnings

255 views
Skip to first unread message

Nicholas Sterling

unread,
Jul 24, 2013, 6:38:35 PM7/24/13
to simple-b...@googlegroups.com
Hi folks.  I am seeing warnings from SBT 0.12.4 and 0.13.0-RC3 (Scala 2.10.2) like this:

[warn] Not a simple type:
[warn] Type: core.NoCtxAttr{type V >: String with Boolean with Int} (class scala.reflect.internal.Types$RefinedType0)
[warn] Transformed: class xsbti.api.Structure

I have spent quite a while trying to isolate this into some reasonable test case, without success -- it disappears on me when I think I have only removed irrelevant code.

When I compile the code with scalac, there are no warnings, so I'm assuming that SBT shouldn't be giving me these warnings (right?).  Also, I asked scalac to tell me about reflective calls, and it didn't see any.

I realize it's kind of lame to post an error without a test case, but so far I haven't been able to do so and I've already spent more time on this than my boss is comfortable with.  At a minimum I wanted to let someone know that this is happening.

As context, I have a class hierarchy that looks something like this:

class      Attr(...) { type V; class Val( val value:V ); ... }
class NoCtxAttr(...) extends      Attr(...) { ... }
class   StrAttr(...) extends NoCtxAttr(...) { type V = String ; ... }
class  BoolAttr(...) extends NoCtxAttr(...) { type V = Boolean; ... }
class   IntAttr(...) extends NoCtxAttr(...) { type V = Int    ; ... }

As you can see, V can be any of String, Boolean, or Int, and presumably that's where the "type V >: String with Boolean with Int" comes from. But something more than the above and some simple uses of these types is required to trigger the problem, and that eludes me.

If there is something straightforward that I can do (e.g. a setting or switch) that will clarify the problem and help me reduce this to a simple test case, I'd be happy to try.

Doug Tangren

unread,
Jul 24, 2013, 7:17:21 PM7/24/13
to simple-b...@googlegroups.com

This doesn't answer the compile question you jad above but the example was so similar to some code I recently wrote I thought I'd share an alternative.

https://github.com/softprops/bintry/blob/master/src/main/scala/attrs.scala#L76

> --
> You received this message because you are subscribed to the Google Groups "simple-build-tool" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to simple-build-t...@googlegroups.com.
> To post to this group, send email to simple-b...@googlegroups.com.
> Visit this group at http://groups.google.com/group/simple-build-tool.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  

Nicholas Sterling

unread,
Jul 25, 2013, 2:49:24 PM7/25/13
to simple-b...@googlegroups.com
@softprops: That's interesting; it does look like you were working on a problem of similar shape.  Thanks.

No takers on whether this is an SBT bug, how to get more info that would help me whittle down the test case, or anything of that sort?

Nicholas

Grzegorz Kossakowski

unread,
Jul 25, 2013, 3:19:44 PM7/25/13
to simple-b...@googlegroups.com
Hi Nicholas,

Thanks for reporting! It would be great to minimize it and I think I can help you.

The warning is coming from sbt when it's trying to index API of your Scala program while compiling. The relevant line is in ExtractAPI.scala file (it got refactored yesterday, before it was API.scala). I'm pretty sure the warning is coming from a point when you refer to NoCtxAttr and not where you declare that type. In order to nail down which source file is causing the problem you'll need to enable debugging output. Try setting scalacOptions to:

scalacOptions ++= Seq("-Ydebug", "-Ylog:xsbt-api")

and then compile and inspect the debug log by invoking `last compile`. In the debug log you should see lines telling you which file sbt is processing at the moment.

Let me know if that helps you figuring out which file is causing problems. Also, my wild guess would be that pattern matcher will be involved in inferring that type we don't expect.

--
Grzegorz Kossakowski
Scalac hacker at Typesafe
twitter: @gkossakowski

Paul Phillips

unread,
Jul 25, 2013, 4:02:52 PM7/25/13
to simple-b...@googlegroups.com
It was pretty easy to send to crashyland. Here's the first one, I think there are more. This by itself doesn't incur the "not a simple type" in sbt (though it does crash it), but I got that message with a more complicated one.

class Attr { class Val }

object Main {
  def f(x: Attr) = x match { case x: Attr => new x.Val }
}

// % scalac3 ./a.scala 
// error: symbol value x does not exist in Main.f
// error: scala.reflect.internal.FatalError: symbol value x does not exist in Main.f
//   at scala.reflect.internal.SymbolTable.abort(SymbolTable.scala:53)
//   at scala.tools.nsc.Global.abort(Global.scala:248)
//   at scala.tools.nsc.backend.icode.GenICode$ICodePhase.genLoadIdent$1(GenICode.scala:884)

Paul Phillips

unread,
Jul 25, 2013, 4:05:44 PM7/25/13
to simple-b...@googlegroups.com
Here's "not a simple type".

class Attr { type V ; class Val }
class StrAttr extends Attr { type V = String }
class BoolAttr extends Attr { type V = Boolean }

object Main {
  def f(x: Attr) = x match {
    case v: StrAttr  => new v.Val
    case v: BoolAttr => new v.Val
  }
}

// [info] Compiling 1 Scala source to /Users/paulp/scratch/simpletype/target/scala-2.10/classes...
// [warn] Not a simple type:
// [warn]  Type: Attr{type V >: String with Boolean} (class scala.reflect.internal.Types$RefinedType0)
// [warn]  Transformed: class xsbti.api.Structure
// [error] symbol value v does not exist in Main.f
// [error] uncaught exception during compilation: scala.reflect.internal.FatalError

Paul Phillips

unread,
Jul 25, 2013, 4:15:36 PM7/25/13
to simple-b...@googlegroups.com
Weird, after patmat v has been eliminated, but it rises from the dead.

// patmat
if (x1.ne(null))
  {
    <synthetic> val x2: Attr = x1;
    matchEnd4(new x2.Val())
  }

// uncurry
if (x1.ne(null))
  {
    <synthetic> val x2: Attr = x1;
    matchEnd4(new v.Val())
  }
    

Nicholas Sterling

unread,
Jul 25, 2013, 5:08:21 PM7/25/13
to simple-b...@googlegroups.com


On 07/25/2013 02:19 PM, Grzegorz Kossakowski wrote:

Thanks for reporting! It would be great to minimize it and I think I can help you.

Yay!  Thanks for responding.



The warning is coming from sbt when it's trying to index API of your Scala program while compiling. The relevant line is in ExtractAPI.scala file (it got refactored yesterday, before it was API.scala). I'm pretty sure the warning is coming from a point when you refer to NoCtxAttr and not where you declare that type. In order to nail down which source file is causing the problem you'll need to enable debugging output. Try setting scalacOptions to:

scalacOptions ++= Seq("-Ydebug", "-Ylog:xsbt-api")

and then compile and inspect the debug log by invoking `last compile`. In the debug log you should see lines telling you which file sbt is processing at the moment.

That's just the kind of help I was looking for -- thanks.

I saw that Paul gave you a couple of things to look at, so if that's good enough, that's fine.  Below is my attempt to do what you asked.

I tried it with SBT 0.12.4 and scalaVersion 2.10.2, but I'm not sure what to make of the output.  Here's the part near the error:
[info] [log xsbt-api(->typer ->parser)] [class] >> scala.annotation.unspecialized
[info] [log xsbt-api(->typer ->parser)] [class] << scala.annotation.unspecialized
[info] [log xsbt-api(->typer ->parser)] ClassfileLoader setting unspecialized.associatedFile = /home/ns/.sbt/boot/scala-2.10.2/lib/scala-library.jar(scala/annotation/unspecialized.class)
[info] [log xsbt-api(->parser)] [class] >> spray.json.JsBoolean
[info] [log xsbt-api(->parser)] [class] << spray.json.JsBoolean
[info] [log xsbt-api(->parser)] ClassfileLoader setting JsBoolean.associatedFile = /home/ns/.ivy2/cache/io.spray/spray-json_2.10/jars/spray-json_2.10-1.2.5.jar(spray/json/JsBoolean.class)

[warn] Not a simple type:
[warn]     Type: core.this.NoCtxAttr{type V >: lang.this.String with scala.this.Boolean with scala.this.Int{}} (class scala.reflect.internal.Types$RefinedType0)
[warn]     Transformed: class xsbti.api.Structure
[info] [log xsbt-api(->parser)] [class] >> java.nio.charset.Charset
[info] [log xsbt-api(->parser)] ClassfileLoader setting Charset.associatedFile = /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre/lib/rt.jar(java/nio/charset/Charset.class)

[warn] Not a simple type:
[warn]     Type: core.this.NoCtxAttr{type V >: scala.this.Boolean with lang.this.String with scala.this.Int with resources.this.VDev.VDevType.Val{}} (class scala.reflect.internal.Types$RefinedType0)
[warn]     Transformed: class xsbti.api.Structure

[warn] Not a simple type:
[warn]     Type: core.this.NoCtxAttr{type V >: scala.this.Long with lang.this.String with lang.this.String with scala.this.Boolean{}} (class scala.reflect.internal.Types$RefinedType0)
[warn]     Transformed: class xsbti.api.Structure

[warn] Not a simple type:
[warn]     Type: core.this.NoCtxAttr{type V >: lang.this.String with scala.this.Boolean{}} (class scala.reflect.internal.Types$RefinedType0)
[warn]     Transformed: class xsbti.api.Structure

[warn] Not a simple type:
[warn]     Type: core.this.NoCtxAttr{type V >: lang.this.String with scala.this.Boolean{}} (class scala.reflect.internal.Types$RefinedType0)
[warn]     Transformed: class xsbti.api.Structure

[warn] Not a simple type:
[warn]     Type: core.this.NoCtxAttr{type V >: scala.this.Int with ZPool.this.ZPoolStatus.Val with scala.this.Long{}} (class scala.reflect.internal.Types$RefinedType0)
[warn]     Transformed: class xsbti.api.Structure
[info] [running phase patmat on 42 compilation units]
[info] [running phase superaccessors on 42 compilation units]
[info] [running phase extmethods on 42 compilation units]
[info] [running phase pickler on 42 compilation units]
The associatedFiles are from spray-json and java.nio, not my code.  You have to go up several hundred lines in the output to find any reference to my code, and none of these associatedFiles are in my code:
$ egrep 'Not a simple type|associated file' outfile
[info] [log xsbt-api(->parser)] ClassfileLoader setting MarshallingContext.associatedFile = /home/ns/.ivy2/cache/io.spray/spray-httpx/jars/spray-httpx-1.2-20130712.jar(spray/httpx/marshalling/MarshallingContext.class)
[info] [log xsbt-api(->typer ->parser)] ClassfileLoader setting specialized.associatedFile = /home/ns/.sbt/boot/scala-2.10.2/lib/scala-library.jar(scala/specialized.class)
[info] [log xsbt-api(->parser)] ClassfileLoader setting SupervisorStrategy.associatedFile = /home/ns/.ivy2/cache/com.typesafe.akka/akka-actor_2.10/jars/akka-actor_2.10-2.2.0.jar(akka/actor/SupervisorStrategy.class)
[info] [log xsbt-api] ClassfileLoader setting AnyParamDefMagnet.associatedFile = /home/ns/.ivy2/cache/io.spray/spray-routing/jars/spray-routing-1.2-20130712.jar(spray/routing/directives/AnyParamDefMagnet.class)
[info] [log xsbt-api(->parser)] ClassfileLoader setting ChunkSizeMagnet.associatedFile = /home/ns/.ivy2/cache/io.spray/spray-routing/jars/spray-routing-1.2-20130712.jar(spray/routing/directives/ChunkSizeMagnet.class)
[info] [log xsbt-api(->parser)] ClassfileLoader setting HttpCookie.associatedFile = /home/ns/.ivy2/cache/io.spray/spray-http/jars/spray-http-1.2-20130712.jar(spray/http/HttpCookie.class)
[info] [log xsbt-api(->parser)] ClassfileLoader setting Decoder.associatedFile = /home/ns/.ivy2/cache/io.spray/spray-httpx/jars/spray-httpx-1.2-20130712.jar(spray/httpx/encoding/Decoder.class)
[info] [log xsbt-api(->parser)] ClassfileLoader setting HttpEncoding.associatedFile = /home/ns/.ivy2/cache/io.spray/spray-http/jars/spray-http-1.2-20130712.jar(spray/http/HttpEncoding.class)
[info] [log xsbt-api(->parser)] ClassfileLoader setting Encoder.associatedFile = /home/ns/.ivy2/cache/io.spray/spray-httpx/jars/spray-httpx-1.2-20130712.jar(spray/httpx/encoding/Encoder.class)
[info] [log xsbt-api(->parser)] ClassfileLoader setting DirectoryListing.associatedFile = /home/ns/.ivy2/cache/io.spray/spray-routing/jars/spray-routing-1.2-20130712.jar(spray/routing/directives/DirectoryListing.class)
[info] [log xsbt-api] ClassfileLoader setting FieldDefMagnet.associatedFile = /home/ns/.ivy2/cache/io.spray/spray-routing/jars/spray-routing-1.2-20130712.jar(spray/routing/directives/FieldDefMagnet.class)
[info] [log xsbt-api] ClassfileLoader setting OnSuccessFutureMagnet.associatedFile = /home/ns/.ivy2/cache/io.spray/spray-routing/jars/spray-routing-1.2-20130712.jar(spray/routing/directives/OnSuccessFutureMagnet.class)
[info] [log xsbt-api(->parser)] ClassfileLoader setting OnFailureFutureMagnet.associatedFile = /home/ns/.ivy2/cache/io.spray/spray-routing/jars/spray-routing-1.2-20130712.jar(spray/routing/directives/OnFailureFutureMagnet.class)
[info] [log xsbt-api(->parser)] ClassfileLoader setting HttpMethod.associatedFile = /home/ns/.ivy2/cache/io.spray/spray-http/jars/spray-http-1.2-20130712.jar(spray/http/HttpMethod.class)
[info] [log xsbt-api(->parser)] ClassfileLoader setting HttpIp.associatedFile = /home/ns/.ivy2/cache/io.spray/spray-http/jars/spray-http-1.2-20130712.jar(spray/http/HttpIp.class)
[info] [log xsbt-api(->parser)] ClassfileLoader setting UUID.associatedFile = /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre/lib/rt.jar(java/util/UUID.class)
[info] [log xsbt-api(->parser)] ClassfileLoader setting MediaTypes.associatedFile = /home/ns/.ivy2/cache/io.spray/spray-http/jars/spray-http-1.2-20130712.jar(spray/http/MediaTypes.class)
[info] [log xsbt-api(->parser)] ClassfileLoader setting MediaType.associatedFile = /home/ns/.ivy2/cache/io.spray/spray-http/jars/spray-http-1.2-20130712.jar(spray/http/MediaType.class)
[info] [log xsbt-api(->parser)] ClassfileLoader setting StandardRoute.associatedFile = /home/ns/.ivy2/cache/io.spray/spray-routing/jars/spray-routing-1.2-20130712.jar(spray/routing/StandardRoute.class)
[info] [log xsbt-api(->parser)] ClassfileLoader setting CompletionMagnet.associatedFile = /home/ns/.ivy2/cache/io.spray/spray-routing/jars/spray-routing-1.2-20130712.jar(spray/routing/directives/CompletionMagnet.class)
[info] [log xsbt-api(->typer ->parser)] ClassfileLoader setting unspecialized.associatedFile = /home/ns/.sbt/boot/scala-2.10.2/lib/scala-library.jar(scala/annotation/unspecialized.class)
[info] [log xsbt-api(->parser)] ClassfileLoader setting JsBoolean.associatedFile = /home/ns/.ivy2/cache/io.spray/spray-json_2.10/jars/spray-json_2.10-1.2.5.jar(spray/json/JsBoolean.class)

[warn] Not a simple type:
[info] [log xsbt-api(->parser)] ClassfileLoader setting Charset.associatedFile = /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre/lib/rt.jar(java/nio/charset/Charset.class)

[warn] Not a simple type:
[warn] Not a simple type:
[warn] Not a simple type:
[warn] Not a simple type:
[warn] Not a simple type:
None of that is mine.  Should I be looking at something else?

Again, if you are fine with Paul's samples, I understand.

Nicholas

Nicholas Sterling

unread,
Jul 25, 2013, 5:55:35 PM7/25/13
to simple-b...@googlegroups.com
Paul, thanks for picking up the baton -- I was getting nowhere!  :^)

Nicholas


Grzegorz Kossakowski

unread,
Jul 26, 2013, 3:11:44 AM7/26/13
to simple-b...@googlegroups.com
Excellent! Thanks Paul. I'll look into that tomorrow. It seems like sbt is not at fault here if genicode is crashing because of the types coming out of patmat as well.

Grzegorz Kossakowski

unread,
Jul 27, 2013, 4:44:27 PM7/27/13
to simple-b...@googlegroups.com
On 25 July 2013 13:02, Paul Phillips <pa...@improving.org> wrote:
It was pretty easy to send to crashyland. Here's the first one, I think there are more. This by itself doesn't incur the "not a simple type" in sbt (though it does crash it), but I got that message with a more complicated one.

class Attr { class Val }

object Main {
  def f(x: Attr) = x match { case x: Attr => new x.Val }
}


I used your bigger sample because I also want to investigate the problem with the inferred type that sbt warns about.

Grzegorz Kossakowski

unread,
Jul 27, 2013, 7:03:34 PM7/27/13
to simple-b...@googlegroups.com


On 27 July 2013 13:44, Grzegorz Kossakowski <grzegorz.k...@gmail.com> wrote:

On 25 July 2013 13:02, Paul Phillips <pa...@improving.org> wrote:
It was pretty easy to send to crashyland. Here's the first one, I think there are more. This by itself doesn't incur the "not a simple type" in sbt (though it does crash it), but I got that message with a more complicated one.

class Attr { class Val }

object Main {
  def f(x: Attr) = x match { case x: Attr => new x.Val }
}

Ticket logged: https://issues.scala-lang.org/browse/SI-7701

I used your bigger sample because I also want to investigate the problem with the inferred type that sbt warns about.

It turns out that the problem on sbt is easier to trigger than I thought, see:

https://github.com/sbt/sbt/issues/830

Thanks Nicholas for reporting!

Nicholas Sterling

unread,
Jul 28, 2013, 12:46:35 AM7/28/13
to simple-b...@googlegroups.com
Thank you guys!

Nicholas

Grzegorz Kossakowski

unread,
Jul 28, 2013, 12:48:32 AM7/28/13
to simple-b...@googlegroups.com
On 27 July 2013 21:46, Nicholas Sterling <nicholas...@gmail.com> wrote:
Thank you guys!

No problem. BTW. If you want to get rid of that warning just annotate types explicitly if it's patmat that is inferring them for you and avoid type projections from refinements.
Reply all
Reply to author
Forward
0 new messages