Seite 1 von 1

Exercise 2 2.6

Verfasst: 21. Nov 2016 16:08
von Faxe
Greetings!

I'm having issues with the provided test files. For instance:

Code: Alles auswählen

class MyTestFileSerializer extends FileSerializer { }
whereas FileSerializer cannot be resolved to a type and I cannot figure out the reason as FileSerializer is in the same package (ex02).

Best Regards

Re: Exercise 2 2.6

Verfasst: 21. Nov 2016 16:11
von ManuelWeiel
Can you supply me with the complete sbt compile error message?

Re: Exercise 2 2.6

Verfasst: 21. Nov 2016 16:11
von Faxe
Do you mean this?

Code: Alles auswählen

Error:(9, 38) not found: type FileSerializer
  class MyTestFileSerializer extends FileSerializer { }

Re: Exercise 2 2.6

Verfasst: 21. Nov 2016 16:21
von ManuelWeiel
Are there any other errors (especially might there be some in PerfSpec.scala)? Without seeing the code, I can otherwise not really tell what the problem might be. If you fail to determine the cause, you might DM me your current implementation and I can take a look.

Re: Exercise 2 2.6

Verfasst: 21. Nov 2016 16:27
von Faxe
Actually I keep getting other compile errors for the tests.

Code: Alles auswählen

Error:scalac: 
     while compiling: ...\ex02\src\test\scala\ex02\FileSerializerTest.scala
        during phase: typer
     library version: version 2.10.4
    compiler version: version 2.10.4
  reconstructed args: -nobootcp -javabootclasspath ; -classpath C:\Program Files\Java\jdk1.8.0_112\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_112\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.8.0_112\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.8.0_112\jre\lib\ext\cldrdata.jar;C:\Program Files\Java\jdk1.8.0_112\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.8.0_112\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.8.0_112\jre\lib\ext\jfxrt.jar;C:\Program Files\Java\jdk1.8.0_112\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.8.0_112\jre\lib\ext\nashorn.jar;C:\Program Files\Java\jdk1.8.0_112\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.8.0_112\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.8.0_112\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.8.0_112\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jdk1.8.0_112\jre\lib\ext\zipfs.jar;C:\Program Files\Java\jdk1.8.0_112\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.8.0_112\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_112\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_112\jre\lib\jfxswt.jar;C:\Program Files\Java\jdk1.8.0_112\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_112\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.8.0_112\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.8.0_112\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_112\jre\lib\rt.jar;...\ex02\out\test\test;X:\OneDrive\Dokumente\ex02\out\production\test;C:\Users\...\.ivy2\cache\org.scala-lang\scala-library\jars\scala-library-2.10.4.jar;C:\Users\...\.ivy2\cache\org.scala-lang\scala-reflect\jars\scala-reflect-2.10.4.jar;D:\...\Downloads\json4s-3.6;D:\...\Downloads\scalatest_2.11-3.0.1.jar;D:\Oliver\Downloads\scalactic_2.11-3.0.1.jar
  last tree to typer: Select(This(package source), Position)
              symbol: object Position in package source (flags: <module>)
   symbol definition: object Position
                 tpe: org.scalactic.source.Position.type
       symbol owners: object Position -> package source
      context owners: value <local FileSerializerTest> -> class FileSerializerTest -> package ex02
== Enclosing template or block ==
Template( // val <local FileSerializerTest>: <notype> in class FileSerializerTest
  "FlatSpec", "Matchers" // parents
  ValDef(
    private
    "_"
    <tpt>
    <empty>
  )
  // 5 statements
  DefDef( // def <init>(): ex02.FileSerializerTest in class FileSerializerTest
    <method>
    "<init>"
    []
    List(Nil)
    <tpt> // tree.tpe=ex02.FileSerializerTest
    Block( // tree.tpe=Unit
      Apply( // def <init>(): org.scalatest.FlatSpec in class FlatSpec, tree.tpe=org.scalatest.FlatSpec
        FileSerializerTest.super."<init>" // def <init>(): org.scalatest.FlatSpec in class FlatSpec, tree.tpe=()org.scalatest.FlatSpec
        Nil
      )
      ()
    )
  )
  ClassDef( // class MyTestFileSerializer extends AnyRef in class FileSerializerTest
    0
    "MyTestFileSerializer"
    []
    Template( // val <local MyTestFileSerializer>: <notype> in class MyTestFileSerializer, tree.tpe=FileSerializerTest.this.MyTestFileSerializer
      "<none>" // parents
      ValDef(
        private
        "_"
        <tpt>
        <empty>
      )
      // 2 statements
      DefDef( // def <init>(): FileSerializerTest.this.MyTestFileSerializer in class MyTestFileSerializer
        <method> <triedcooking>
        "<init>"
        []
        List(Nil)
        <tpt> // tree.tpe=FileSerializerTest.this.MyTestFileSerializer
        Block( // tree.tpe=Unit
          Apply( // def <init>(): Object in class Object, tree.tpe=Object
            MyTestFileSerializer.super."<init>" // def <init>(): Object in class Object, tree.tpe=()Object
            Nil
          )
          ()
        )
      )
      <empty>
    )
  )
  ValDef( // private[this] val fs: FileSerializerTest.this.MyTestFileSerializer in class FileSerializerTest
    private <local> <triedcooking>
    "fs"
    <tpt> // tree.tpe=FileSerializerTest.this.MyTestFileSerializer
    Apply(
      new MyTestFileSerializer."<init>"
      Nil
    )
  )
  Apply(
    "deserialize after serialize".should("contain serialized entry")."in"
    Block(
      // 3 statements
      ValDef(
        0
        "f"
        <tpt>
        Apply(
          "fs"."fileForName"
          "test1"
        )
      )
      If(
        Apply(
          "Files"."exists"
          "f"
        )
        Apply(
          "Files"."delete"
          "f"
        )
        ()
      )
      Apply(
        "fs"."serialize"
        // 3 arguments
        "test1"
        42
        "truth"
      )
      Apply(
        fs.deserialize("test1")."last"."_2"."should"
        Apply(
          "equal"
          42
        )
      )
    )
  )
  Apply(
    "desiralize for one name".should("not affect others")."in"
    Block(
      // 5 statements
      ValDef(
        0
        "f"
        <tpt>
        Apply(
          "fs"."fileForName"
          "test1"
        )
      )
      If(
        Apply(
          "Files"."exists"
          "f"
        )
        Apply(
          "Files"."delete"
          "f"
        )
        ()
      )
      ValDef(
        0
        "f2"
        <tpt>
        Apply(
          "fs"."fileForName"
          "test2"
        )
      )
      If(
        Apply(
          "Files"."exists"
          "f2"
        )
        Apply(
          "Files"."delete"
          "f2"
        )
        ()
      )
      Apply(
        "fs"."serialize"
        // 3 arguments
        "test1"
        42
        "truth"
      )
      Apply(
        fs.deserialize("test2")."isEmpty"."should"
        Apply(
          "be"
          true
        )
      )
    )
  )
)
== Expanded type of tree ==
SingleType(pre = ThisType(package source), object Position)
uncaught exception during compilation: scala.MatchError

Code: Alles auswählen

Error:scalac: Error: false (of class scala.reflect.internal.Trees$Literal)
scala.MatchError: false (of class scala.reflect.internal.Trees$Literal)

	at scala.tools.nsc.typechecker.Macros$MacroImplBinding$.unpickleAtom(Macros.scala:118)

	at scala.tools.nsc.typechecker.Macros$MacroImplBinding$$anonfun$6.apply(Macros.scala:186)

	at scala.tools.nsc.typechecker.Macros$MacroImplBinding$$anonfun$6.apply(Macros.scala:186)

	at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)

	at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)

	at scala.collection.immutable.List.foreach(List.scala:318)

	at scala.collection.TraversableLike$class.map(TraversableLike.scala:244)

	at scala.collection.AbstractTraversable.map(Traversable.scala:105)

	at scala.tools.nsc.typechecker.Macros$MacroImplBinding$.unpickle(Macros.scala:186)

	at scala.tools.nsc.typechecker.Macros$class.scala$tools$nsc$typechecker$Macros$$loadMacroImplBinding(Macros.scala:205)

	at scala.tools.nsc.typechecker.Macros$$anonfun$scala$tools$nsc$typechecker$Macros$$macroRuntime$3.apply(Macros.scala:522)

	at scala.tools.nsc.typechecker.Macros$$anonfun$scala$tools$nsc$typechecker$Macros$$macroRuntime$3.apply(Macros.scala:521)

	at scala.collection.mutable.MapLike$class.getOrElseUpdate(MapLike.scala:189)

	at scala.collection.mutable.AbstractMap.getOrElseUpdate(Map.scala:91)

	at scala.tools.nsc.typechecker.Macros$class.scala$tools$nsc$typechecker$Macros$$macroRuntime(Macros.scala:521)

	at scala.tools.nsc.typechecker.Macros$$anonfun$scala$tools$nsc$typechecker$Macros$$macroExpand1$1.apply(Macros.scala:795)

	at scala.tools.nsc.typechecker.Macros$$anonfun$scala$tools$nsc$typechecker$Macros$$macroExpand1$1.apply(Macros.scala:787)

	at scala.tools.nsc.Global.withInfoLevel(Global.scala:190)

	at scala.tools.nsc.typechecker.Macros$class.scala$tools$nsc$typechecker$Macros$$macroExpand1(Macros.scala:787)

	at scala.tools.nsc.typechecker.Macros$class.macroExpand(Macros.scala:701)

	at scala.tools.nsc.Global$$anon$1.macroExpand(Global.scala:493)

	at scala.tools.nsc.typechecker.Typers$Typer.adapt(Typers.scala:1152)

	at scala.tools.nsc.typechecker.Typers$Typer.adapt(Typers.scala:1102)

	at scala.tools.nsc.typechecker.Implicits$ImplicitSearch.typedImplicit1(Implicits.scala:679)

	at scala.tools.nsc.typechecker.Implicits$ImplicitSearch.typedImplicit0(Implicits.scala:631)

	at scala.tools.nsc.typechecker.Implicits$ImplicitSearch.pre211DivergenceLogic$1(Implicits.scala:468)

	at scala.tools.nsc.typechecker.Implicits$ImplicitSearch.scala$tools$nsc$typechecker$Implicits$ImplicitSearch$$typedImplicit(Implicits.scala:499)

	at scala.tools.nsc.typechecker.Implicits$ImplicitSearch$ImplicitComputation.pre211tryImplicitInfo$1(Implicits.scala:932)

	at scala.tools.nsc.typechecker.Implicits$ImplicitSearch$ImplicitComputation.rankImplicits(Implicits.scala:940)

	at scala.tools.nsc.typechecker.Implicits$ImplicitSearch$ImplicitComputation.findBest(Implicits.scala:979)

	at scala.tools.nsc.typechecker.Implicits$ImplicitSearch.searchImplicit(Implicits.scala:1040)

	at scala.tools.nsc.typechecker.Implicits$ImplicitSearch.bestImplicit(Implicits.scala:1427)

	at scala.tools.nsc.typechecker.Implicits$class.inferImplicit(Implicits.scala:82)

	at scala.tools.nsc.Global$$anon$1.inferImplicit(Global.scala:493)

	at scala.tools.nsc.typechecker.Implicits$class.inferImplicit(Implicits.scala:37)

	at scala.tools.nsc.Global$$anon$1.inferImplicit(Global.scala:493)

	at scala.tools.nsc.typechecker.Typers$Typer.applyImplicitArgs(Typers.scala:127)

	at scala.tools.nsc.typechecker.Typers$Typer.adaptToImplicitMethod$1(Typers.scala:869)

	at scala.tools.nsc.typechecker.Typers$Typer.adapt(Typers.scala:1126)

	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5660)

	at scala.tools.nsc.typechecker.Typers$Typer.typedQualifier(Typers.scala:5727)

	at scala.tools.nsc.typechecker.Typers$Typer.typedQualifier(Typers.scala:5735)

	at scala.tools.nsc.typechecker.Typers$Typer.adaptToMember(Typers.scala:1349)

	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$18.apply(Typers.scala:1400)

	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$18.apply(Typers.scala:1400)

	at scala.tools.nsc.typechecker.Typers$Typer.silent(Typers.scala:745)

	at scala.tools.nsc.typechecker.Typers$Typer.adaptToMemberWithArgs(Typers.scala:1400)

	at scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$typedSelect$1(Typers.scala:4793)

	at scala.tools.nsc.typechecker.Typers$Typer.typedSelectOrSuperCall$1(Typers.scala:4933)

	at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5563)

	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5642)

	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$93.apply(Typers.scala:4608)

	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$93.apply(Typers.scala:4608)

	at scala.tools.nsc.typechecker.Typers$Typer.silent(Typers.scala:727)

	at scala.tools.nsc.typechecker.Typers$Typer.normalTypedApply$1(Typers.scala:4608)

	at scala.tools.nsc.typechecker.Typers$Typer.typedApply$1(Typers.scala:4659)

	at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5564)

	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5642)

	at scala.tools.nsc.typechecker.Typers$Typer.typedQualifier(Typers.scala:5727)

	at scala.tools.nsc.typechecker.Typers$Typer.typedQualifier(Typers.scala:5733)

	at scala.tools.nsc.typechecker.Typers$Typer.typedSelectOrSuperCall$1(Typers.scala:4913)

	at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5563)

	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5642)

	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$93.apply(Typers.scala:4608)

	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$93.apply(Typers.scala:4608)

	at scala.tools.nsc.typechecker.Typers$Typer.silent(Typers.scala:727)

	at scala.tools.nsc.typechecker.Typers$Typer.normalTypedApply$1(Typers.scala:4608)

	at scala.tools.nsc.typechecker.Typers$Typer.typedApply$1(Typers.scala:4659)

	at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5564)

	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5642)

	at scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$typedStat$1(Typers.scala:2928)

	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$61.apply(Typers.scala:3032)

	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$61.apply(Typers.scala:3032)

	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:3032)

	at scala.tools.nsc.typechecker.Typers$Typer.typedTemplate(Typers.scala:1919)

	at scala.tools.nsc.typechecker.Typers$Typer.typedClassDef(Typers.scala:1759)

	at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5583)

	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5642)

	at scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$typedStat$1(Typers.scala:2928)

	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$61.apply(Typers.scala:3032)

	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$61.apply(Typers.scala:3032)

	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:3032)

	at scala.tools.nsc.typechecker.Typers$Typer.typedPackageDef$1(Typers.scala:5301)

	at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5587)

	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5642)

	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5704)

	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:115)

	at xsbt.CachedCompiler0.run(CompilerInterface.scala:94)

	at xsbt.CompilerInterface.run(CompilerInterface.scala:22)

	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

	at java.lang.reflect.Method.invoke(Method.java:498)

	at sbt.compiler.AnalyzingCompiler.call(AnalyzingCompiler.scala:101)

	at sbt.compiler.AnalyzingCompiler.compile(AnalyzingCompiler.scala:47)

	at sbt.compiler.AnalyzingCompiler.compile(AnalyzingCompiler.scala:41)

	at org.jetbrains.jps.incremental.scala.local.IdeaIncrementalCompiler.compile(IdeaIncrementalCompiler.scala:29)

	at org.jetbrains.jps.incremental.scala.local.LocalServer.compile(LocalServer.scala:26)

	at org.jetbrains.jps.incremental.scala.remote.Main$.make(Main.scala:67)

	at org.jetbrains.jps.incremental.scala.remote.Main$.nailMain(Main.scala:24)

	at org.jetbrains.jps.incremental.scala.remote.Main.nailMain(Main.scala)

	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

	at java.lang.reflect.Method.invoke(Method.java:498)

	at com.martiansoftware.nailgun.NGSession.run(NGSession.java:319)

I hope this is somewhat helpful.

Best Regards

Re: Exercise 2 2.6

Verfasst: 21. Nov 2016 16:51
von ManuelWeiel
OK. So the Scala compiler does continue to compile even after errors, but errors might still "chain", so one error might cause others until the Scala compiler stops.

Fix the first error that appears first, and the other errors might "fix" themselves.

Re: Exercise 2 2.6

Verfasst: 21. Nov 2016 16:55
von ManuelWeiel
Also these errors suggest, that something in the compiler got seriously messed up.
Also it seems that you are using IntelliJ and there might be a problem with its incremental compiler.

To be on the safe side run sbt clean and then sbt compile on the commandline to check that its not a problem with incremental compilation.

Re: Exercise 2 2.6

Verfasst: 21. Nov 2016 17:31
von Faxe
Thanks for your help! It is indeed in issue with IntelliJ as using sbt on commandline has no issues.