Scala conversion to Java function never terminatesImplicit conversion from Scala function to Java FunctionScala vs. Groovy vs. ClojureIs the Scala 2.8 collections library a case of “the longest suicide note in history”?Difference between object and class in ScalaScala puts precedence on implicit conversion over “natural” operations… Why? Is this a bug? Or am I doing something wrong?What are all the uses of an underscore in Scala?Extracting implicit conversion exceptions in partially applied functionsImplicit conversions in scala within a class, why and why not?What method conversion has been applied to this example?Implicit conversions for defs/lambdas in Scala?Implicit Functions in Scala. How is this working?

Meaning of 'ran' in German?

Should we use wheatstone bridges nowadays?

Does Sitecore have support for Sitecore products in containers?

Is the mass of paint relevant in rocket design?

Is it more effective to add yeast before or after kneading?

If an object moving in a circle experiences centripetal force, then doesn't it also experience centrifugal force, because of Newton's third law?

Received a package but didn't order it

extracting sublists

1, 2, 4, 8, 16, ... 33?

Is it a good idea to leave minor world details to the reader's imagination?

How do you use the interjection for snorting?

Hilbert's hotel: why can't I repeat it infinitely many times?

Cut a cake into 3 equal portions with only a knife

Co-supervisor comes to the office to help her students, which distracts me

Is it allowed to buy a Probe Bahncard 50 repeatedly?

Is it acceptable to say that a reviewer's concern is not going to be addressed because then the paper would be too long?

Why did the Soviet Union not "grant" Inner Mongolia to Mongolia after World War Two?

How to create fractional SI units (SI...sqrts)?

Does "as soon as" imply simultaneity?

Line segments inside a square

My manager quit. Should I agree to defer wage increase to accommodate budget concerns?

Does HSTS protect against a rogue CA issuing a illegitimate valid certificate?

How 象【しょう】 ( ≈かたち、 すがた、ようす) and 象【ぞう】 (どうぶつ) got to be written with the same kanji?

On the meaning of 'anyways' in "What Exactly Is a Quartz Crystal, Anyways?"



Scala conversion to Java function never terminates


Implicit conversion from Scala function to Java FunctionScala vs. Groovy vs. ClojureIs the Scala 2.8 collections library a case of “the longest suicide note in history”?Difference between object and class in ScalaScala puts precedence on implicit conversion over “natural” operations… Why? Is this a bug? Or am I doing something wrong?What are all the uses of an underscore in Scala?Extracting implicit conversion exceptions in partially applied functionsImplicit conversions in scala within a class, why and why not?What method conversion has been applied to this example?Implicit conversions for defs/lambdas in Scala?Implicit Functions in Scala. How is this working?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I wrote an implicit conversion from Scala functions to Java functions:



import java.util.function.Function => JavaFunction

implicit def toJavaFunction[T, V](f: (T) => V): JavaFunction[T, V] =
new JavaFunction[T, V]
override def apply(input: T) = f(input)




However, IntelliJ suggests converting this to a single abstract method:



implicit def toJavaFunction[T, V](f: (T) => V): JavaFunction[T, V] = 
(input: T) => f(input)



When I change to the second implementation, functions wrapped in this method run forever and execution never terminates. What's different about the second method that's causing it to behave this way? Is there something that IntelliJ is missing?










share|improve this question
























  • Which version of Scala are you using? Probably the problem is that on your second example basically it seems you are calling yourself recursively... Just that, that's not true, at least since 2.12 (I believe this was introduced since 2.11, but not sure tough) that conversion already exists (I can just write this on the REL ` val jf: java.util.function.Function[String, Int] = s => s.toInt`), which probably is why Intellij suggest the change. I tested your second example on the RELP and it works too, so I am not sure what would be the problem on your case.

    – Luis Miguel Mejía Suárez
    Mar 28 at 18:07






  • 1





    @LuisMiguelMejíaSuárez That the s => s.toInt is accepted as java.util.function.Function is not an implicit conversion, it's the SAM. I also couldn't reproduce the problem.

    – Andrey Tyukin
    Mar 28 at 18:37











  • @AndreyTyukin Thanks for the clarification, I already knew that it was not an implicit conversion, but something more low level on the compiler. However, did not know what it was. So, thanks for the info both for me and for those reading this.

    – Luis Miguel Mejía Suárez
    Mar 28 at 18:53











  • This is on version 2.11. I added the -Xexperimental flag to my compiler options and now the second option is working as well. I wonder if I have a config mismatch or something in IntelliJ that's telling it that SAM is available by default.

    – pbeardshear
    Mar 28 at 18:57











  • Please check stackoverflow.com/questions/36828074/…. Looks like duplicate question.

    – KZapagol
    Mar 29 at 9:18

















0















I wrote an implicit conversion from Scala functions to Java functions:



import java.util.function.Function => JavaFunction

implicit def toJavaFunction[T, V](f: (T) => V): JavaFunction[T, V] =
new JavaFunction[T, V]
override def apply(input: T) = f(input)




However, IntelliJ suggests converting this to a single abstract method:



implicit def toJavaFunction[T, V](f: (T) => V): JavaFunction[T, V] = 
(input: T) => f(input)



When I change to the second implementation, functions wrapped in this method run forever and execution never terminates. What's different about the second method that's causing it to behave this way? Is there something that IntelliJ is missing?










share|improve this question
























  • Which version of Scala are you using? Probably the problem is that on your second example basically it seems you are calling yourself recursively... Just that, that's not true, at least since 2.12 (I believe this was introduced since 2.11, but not sure tough) that conversion already exists (I can just write this on the REL ` val jf: java.util.function.Function[String, Int] = s => s.toInt`), which probably is why Intellij suggest the change. I tested your second example on the RELP and it works too, so I am not sure what would be the problem on your case.

    – Luis Miguel Mejía Suárez
    Mar 28 at 18:07






  • 1





    @LuisMiguelMejíaSuárez That the s => s.toInt is accepted as java.util.function.Function is not an implicit conversion, it's the SAM. I also couldn't reproduce the problem.

    – Andrey Tyukin
    Mar 28 at 18:37











  • @AndreyTyukin Thanks for the clarification, I already knew that it was not an implicit conversion, but something more low level on the compiler. However, did not know what it was. So, thanks for the info both for me and for those reading this.

    – Luis Miguel Mejía Suárez
    Mar 28 at 18:53











  • This is on version 2.11. I added the -Xexperimental flag to my compiler options and now the second option is working as well. I wonder if I have a config mismatch or something in IntelliJ that's telling it that SAM is available by default.

    – pbeardshear
    Mar 28 at 18:57











  • Please check stackoverflow.com/questions/36828074/…. Looks like duplicate question.

    – KZapagol
    Mar 29 at 9:18













0












0








0








I wrote an implicit conversion from Scala functions to Java functions:



import java.util.function.Function => JavaFunction

implicit def toJavaFunction[T, V](f: (T) => V): JavaFunction[T, V] =
new JavaFunction[T, V]
override def apply(input: T) = f(input)




However, IntelliJ suggests converting this to a single abstract method:



implicit def toJavaFunction[T, V](f: (T) => V): JavaFunction[T, V] = 
(input: T) => f(input)



When I change to the second implementation, functions wrapped in this method run forever and execution never terminates. What's different about the second method that's causing it to behave this way? Is there something that IntelliJ is missing?










share|improve this question














I wrote an implicit conversion from Scala functions to Java functions:



import java.util.function.Function => JavaFunction

implicit def toJavaFunction[T, V](f: (T) => V): JavaFunction[T, V] =
new JavaFunction[T, V]
override def apply(input: T) = f(input)




However, IntelliJ suggests converting this to a single abstract method:



implicit def toJavaFunction[T, V](f: (T) => V): JavaFunction[T, V] = 
(input: T) => f(input)



When I change to the second implementation, functions wrapped in this method run forever and execution never terminates. What's different about the second method that's causing it to behave this way? Is there something that IntelliJ is missing?







scala






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 28 at 17:41









pbeardshearpbeardshear

4913 silver badges8 bronze badges




4913 silver badges8 bronze badges















  • Which version of Scala are you using? Probably the problem is that on your second example basically it seems you are calling yourself recursively... Just that, that's not true, at least since 2.12 (I believe this was introduced since 2.11, but not sure tough) that conversion already exists (I can just write this on the REL ` val jf: java.util.function.Function[String, Int] = s => s.toInt`), which probably is why Intellij suggest the change. I tested your second example on the RELP and it works too, so I am not sure what would be the problem on your case.

    – Luis Miguel Mejía Suárez
    Mar 28 at 18:07






  • 1





    @LuisMiguelMejíaSuárez That the s => s.toInt is accepted as java.util.function.Function is not an implicit conversion, it's the SAM. I also couldn't reproduce the problem.

    – Andrey Tyukin
    Mar 28 at 18:37











  • @AndreyTyukin Thanks for the clarification, I already knew that it was not an implicit conversion, but something more low level on the compiler. However, did not know what it was. So, thanks for the info both for me and for those reading this.

    – Luis Miguel Mejía Suárez
    Mar 28 at 18:53











  • This is on version 2.11. I added the -Xexperimental flag to my compiler options and now the second option is working as well. I wonder if I have a config mismatch or something in IntelliJ that's telling it that SAM is available by default.

    – pbeardshear
    Mar 28 at 18:57











  • Please check stackoverflow.com/questions/36828074/…. Looks like duplicate question.

    – KZapagol
    Mar 29 at 9:18

















  • Which version of Scala are you using? Probably the problem is that on your second example basically it seems you are calling yourself recursively... Just that, that's not true, at least since 2.12 (I believe this was introduced since 2.11, but not sure tough) that conversion already exists (I can just write this on the REL ` val jf: java.util.function.Function[String, Int] = s => s.toInt`), which probably is why Intellij suggest the change. I tested your second example on the RELP and it works too, so I am not sure what would be the problem on your case.

    – Luis Miguel Mejía Suárez
    Mar 28 at 18:07






  • 1





    @LuisMiguelMejíaSuárez That the s => s.toInt is accepted as java.util.function.Function is not an implicit conversion, it's the SAM. I also couldn't reproduce the problem.

    – Andrey Tyukin
    Mar 28 at 18:37











  • @AndreyTyukin Thanks for the clarification, I already knew that it was not an implicit conversion, but something more low level on the compiler. However, did not know what it was. So, thanks for the info both for me and for those reading this.

    – Luis Miguel Mejía Suárez
    Mar 28 at 18:53











  • This is on version 2.11. I added the -Xexperimental flag to my compiler options and now the second option is working as well. I wonder if I have a config mismatch or something in IntelliJ that's telling it that SAM is available by default.

    – pbeardshear
    Mar 28 at 18:57











  • Please check stackoverflow.com/questions/36828074/…. Looks like duplicate question.

    – KZapagol
    Mar 29 at 9:18
















Which version of Scala are you using? Probably the problem is that on your second example basically it seems you are calling yourself recursively... Just that, that's not true, at least since 2.12 (I believe this was introduced since 2.11, but not sure tough) that conversion already exists (I can just write this on the REL ` val jf: java.util.function.Function[String, Int] = s => s.toInt`), which probably is why Intellij suggest the change. I tested your second example on the RELP and it works too, so I am not sure what would be the problem on your case.

– Luis Miguel Mejía Suárez
Mar 28 at 18:07





Which version of Scala are you using? Probably the problem is that on your second example basically it seems you are calling yourself recursively... Just that, that's not true, at least since 2.12 (I believe this was introduced since 2.11, but not sure tough) that conversion already exists (I can just write this on the REL ` val jf: java.util.function.Function[String, Int] = s => s.toInt`), which probably is why Intellij suggest the change. I tested your second example on the RELP and it works too, so I am not sure what would be the problem on your case.

– Luis Miguel Mejía Suárez
Mar 28 at 18:07




1




1





@LuisMiguelMejíaSuárez That the s => s.toInt is accepted as java.util.function.Function is not an implicit conversion, it's the SAM. I also couldn't reproduce the problem.

– Andrey Tyukin
Mar 28 at 18:37





@LuisMiguelMejíaSuárez That the s => s.toInt is accepted as java.util.function.Function is not an implicit conversion, it's the SAM. I also couldn't reproduce the problem.

– Andrey Tyukin
Mar 28 at 18:37













@AndreyTyukin Thanks for the clarification, I already knew that it was not an implicit conversion, but something more low level on the compiler. However, did not know what it was. So, thanks for the info both for me and for those reading this.

– Luis Miguel Mejía Suárez
Mar 28 at 18:53





@AndreyTyukin Thanks for the clarification, I already knew that it was not an implicit conversion, but something more low level on the compiler. However, did not know what it was. So, thanks for the info both for me and for those reading this.

– Luis Miguel Mejía Suárez
Mar 28 at 18:53













This is on version 2.11. I added the -Xexperimental flag to my compiler options and now the second option is working as well. I wonder if I have a config mismatch or something in IntelliJ that's telling it that SAM is available by default.

– pbeardshear
Mar 28 at 18:57





This is on version 2.11. I added the -Xexperimental flag to my compiler options and now the second option is working as well. I wonder if I have a config mismatch or something in IntelliJ that's telling it that SAM is available by default.

– pbeardshear
Mar 28 at 18:57













Please check stackoverflow.com/questions/36828074/…. Looks like duplicate question.

– KZapagol
Mar 29 at 9:18





Please check stackoverflow.com/questions/36828074/…. Looks like duplicate question.

– KZapagol
Mar 29 at 9:18












0






active

oldest

votes














Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);














draft saved

draft discarded
















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55403844%2fscala-conversion-to-java-function-never-terminates%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55403844%2fscala-conversion-to-java-function-never-terminates%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현