Navigation Menu

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 crash with Java repeated parameters #3622

Closed
scabug opened this issue Jun 29, 2010 · 3 comments
Closed

Compiler crash with Java repeated parameters #3622

scabug opened this issue Jun 29, 2010 · 3 comments
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented Jun 29, 2010

scalac 2.8.0.x crashes when compiling the following 3 source files (strongly reduced source code from Android project Wiktionary):

//AsyncTask.java
public abstract class AsyncTask<Params, Progress, Result> {
    protected abstract Result doInBackground(Params... args);
}
//MyAsyncTask.java
public abstract class MyAsyncTask extends AsyncTask<String, String, String> {
    protected abstract String doInBackground1(String[] args);
    @Override
    protected String doInBackground(String... args) {
        return doInBackground1(new String[]{"dummy"});
    }
}
//Test.scala
class Test extends MyAsyncTask {
  protected def doInBackground1(args: Array[String]): String = ""
}
I've attached 2 error output logs I generated without resp. with the following line added in `Types.scala` (to Adriaan: "the compiler build crashes during the `quick` phase when the assert in enabled !!):

Index: src/compiler/scala/tools/nsc/symtab/Types.scala

--- src/compiler/scala/tools/nsc/symtab/Types.scala (revision 22422)
+++ src/compiler/scala/tools/nsc/symtab/Types.scala (working copy)
@@ -1881,6 +1881,7 @@

object TypeRef extends TypeRefExtractor {
def apply(pre: Type, sym: Symbol, args: List[Type]): Type = {

  •  //assert((sym ne JavaRepeatedParamClass) || args.nonEmpty)
     class rawTypeRef extends TypeRef(pre, sym, args) with UniqueType
     unique(new rawTypeRef)
    
    }
My current workaround is the following:

Index: src/compiler/scala/tools/nsc/transform/UnCurry.scala

--- src/compiler/scala/tools/nsc/transform/UnCurry.scala (revision 22422)
+++ src/compiler/scala/tools/nsc/transform/UnCurry.scala (working copy)
@@ -72,7 +72,7 @@
apply(appliedType(SeqClass.typeConstructor, args))
case TypeRef(pre, JavaRepeatedParamClass, args) =>
apply(arrayType(

  •        if (isUnboundedGeneric(args.head)) ObjectClass.tpe else args.head))
    
  •        if (args.isEmpty || isUnboundedGeneric(args.head)) ObjectClass.tpe else args.head))
       case _ =>
         expandAlias(mapOver(tp))
     }
    

{code}

@scabug
Copy link
Author

scabug commented Jun 29, 2010

Imported From: https://issues.scala-lang.org/browse/SI-3622?orig=1
Reporter: @michelou
Attachments:

@scabug
Copy link
Author

scabug commented Jul 7, 2010

@adriaanm said:
fix will land in trunk later this week, already available in my repo: http://github.com/adriaanm/scala/commit/5c45fb3daca42a8b8057c84ea888e65a3bbc06c6

@scabug
Copy link
Author

scabug commented Jul 8, 2010

@adriaanm said:
(In r22519) closes #3622: refchecks erased types without uncurrying them first
review by odersky

@scabug scabug closed this as completed May 18, 2011
@scabug scabug added this to the 2.8.1 milestone Apr 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants