Created
November 1, 2017 02:17
-
-
Save ItsDoot/de109bdddbd22e4327334e62693076e2 to your computer and use it in GitHub Desktop.
Unsafe type casting in Ceylon (through Java)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ceylon.language.SharedAnnotation$annotation$; | |
import com.redhat.ceylon.compiler.java.metadata.*; | |
import com.redhat.ceylon.compiler.java.runtime.model.TypeDescriptor; | |
import java.lang.Object; | |
@Ceylon(major = 8) | |
@Method | |
public class unsafeCast_ { | |
private unsafeCast_() { | |
} | |
@SuppressWarnings("unchecked") | |
@SharedAnnotation$annotation$ | |
@TypeInfo("T") | |
@TypeParameters({@TypeParameter(value = "T", variance = Variance.IN)}) | |
public static <T> T unsafeCast(@Ignore final TypeDescriptor $reified$T, | |
@Name("o") @TypeInfo("ceylon.language::Anything") final Object o) { | |
return (T) o; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment