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

Implements Type to BType conversion. #1145

Merged

Conversation

wpopielarski
Copy link
Member

@wpopielarski wpopielarski commented Mar 7, 2017

There is still failing test for ScalaJavaMapper
Depends on scala/scala#5773

@ghprb-bot
Copy link

Test FAILed.

case sym if sym == definitions.NothingClass => "Lscala/Nothing;"
case sym if sym.isTypeParameterOrSkolem => "Ljava/lang/Object;"
case definitions.ArrayClass => ARRAY_TAG + toJavaDescriptor(args.head)
case _ => OBJECT_TAG + sym.javaClassName.replace('.', '/')+";"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is javaClassName.replace... better than javaBinaryName?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

javaBinaryNameString seems to be optimal

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually looks like they are giving same string. I look into it deeper. Anyway test with List is failing so there is space to make thing better.
Other thing is Lscala/Null;, I saw in code something like Lscala/runtime/Null;. I have to verify it

if (prefix != "") prefix + "." + tpe.sym.nameString
import rootMirror.getPackageIfDefined
val pkg = getPackageIfDefined(TermName(prefix))
if (prefix != "" && pkg != definitions.ScalaPackage) prefix + "." + tpe.sym.nameString
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this doing exactly? Can you give an example? Is it omitting the scala prefix?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, it is skipping scala package

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aha! Right where my investigation ended :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if I like like this change. When is it useful to not display the scala package?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are test failures because without this change scala.Predef.String is displayed as scala.String as opposed to just String

@ghprb-bot
Copy link

Test FAILed.

@kiritsuku
Copy link
Member

There are lots of failing tests on Jenkins. What a nuisance.

@ghprb-bot
Copy link

Test FAILed.

case DOUBLE => C_DOUBLE.toString
case ClassBType(cls) => s"L$cls;"
case ArrayBType(elem) => s"[${javaDescriptor(elem)}"
private def toJavaDescriptor(tpe: Type): String = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lrytz Could you have a look at this function? Maybe you can tell us if it is a good replacement for the function above. We want to get rid of BType but it has quite a complex implementation and therefore we do not know if we covered all cases.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the compiler phase this function is running at?

case DOUBLE => C_DOUBLE.toString
case ClassBType(cls) => s"L$cls;"
case ArrayBType(elem) => s"[${javaDescriptor(elem)}"
private def toJavaDescriptor(tpe: Type): String = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the compiler phase this function is running at?

import scala.reflect.internal.ClassfileConstants._
val (sym, args) = tpe match {
case TypeRef(_, sym, args) => (sym, args)
case rt @ RefinedType(_, _) => (rt.typeSymbol, rt.typeArgs)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This match is very non-exhaustive - how can you know that no other types reach here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function runs in the presentation compiler. We don't have access to the backend here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I mean is types like ThisType, ConstantType, ExistentialType, AnnotatedType, etc: https://github.com/scala/scala/blob/v2.12.1/src/reflect/scala/reflect/internal/Types.scala#L22-L75

@ghprb-bot
Copy link

Test FAILed.

@wpopielarski
Copy link
Member Author

Depends on scala/scala#5773

@kiritsuku
Copy link
Member

retest this please

@kiritsuku kiritsuku changed the title [WIP] Implements Type to BType conversion. Implements Type to BType conversion. Mar 27, 2017
@kiritsuku
Copy link
Member

Tests are still failing on Jenkins. I merge anyway, we can look at this in a different PR.

@kiritsuku kiritsuku merged commit e2b2dd8 into scala-ide:2.12-compatibility Mar 27, 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
5 participants