-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[J2KT] Move already passing readables from
j2ktnotpassing
to j2kt
…
…, and non-passing pieces as commented-out and assigned with a bug. PiperOrigin-RevId: 725600446
- Loading branch information
1 parent
10f52d2
commit 17f1290
Showing
30 changed files
with
540 additions
and
164 deletions.
There are no files selected for viewing
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
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
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
46 changes: 46 additions & 0 deletions
46
transpiler/javatests/com/google/j2cl/readable/java/j2kt/DefaultNullable.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright 2022 Google Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package j2kt; | ||
|
||
import org.jspecify.annotations.NullMarked; | ||
import org.jspecify.annotations.Nullable; | ||
|
||
public class DefaultNullable { | ||
// TODO(b/395585494): Uncomment when fixed | ||
// static void testNonNullableLambdas() { | ||
// NotNullable.Consumer<String> methodReference = DefaultNullable::accept; | ||
// } | ||
|
||
static void accept(String s) {} | ||
} | ||
|
||
@NullMarked | ||
class NotNullable { | ||
interface Consumer<T extends @Nullable Object> { | ||
void accept(T t); | ||
} | ||
} | ||
|
||
@NullMarked | ||
abstract class Ordering<T extends @Nullable Object> { | ||
<S extends T> Ordering<S> reverse() { | ||
return null; | ||
} | ||
|
||
static <E extends @Nullable Object> Ordering<? super E> reversed(Ordering<? super E> ordering) { | ||
return ordering.reverse(); | ||
} | ||
} |
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
42 changes: 42 additions & 0 deletions
42
...er/javatests/com/google/j2cl/readable/java/j2kt/InitializationProblemWithNullLiteral.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright 2024 Google Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package j2kt; | ||
|
||
import org.jspecify.annotations.NullMarked; | ||
import org.jspecify.annotations.Nullable; | ||
|
||
@NullMarked | ||
public class InitializationProblemWithNullLiteral { | ||
static class Foo<V extends @Nullable Object> { | ||
static <V extends @Nullable Object> Foo<V> with(V v) { | ||
return new Foo<>(); | ||
} | ||
} | ||
|
||
// Kotlin complains that this field is uninitialized, while the actual problems is hidden in the | ||
// next field, which uses null literal in generic method invocation, with type inferred as | ||
// wildcard from assignment. | ||
final int completelyNormalFinalField; | ||
|
||
// The workaround for this problem specifying explicit type argument: | ||
// {@code Foo.<@Nullable Void>.with(null)} | ||
// TODO(b/372305346): Uncomment when fixed | ||
// Foo<?> problematicFoo = Foo.with(null); | ||
|
||
InitializationProblemWithNullLiteral() { | ||
this.completelyNormalFinalField = 0; | ||
} | ||
} |
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
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
45 changes: 45 additions & 0 deletions
45
transpiler/javatests/com/google/j2cl/readable/java/j2kt/UnsatisfiedTypeBounds.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright 2022 Google Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package j2kt; | ||
|
||
import org.jspecify.annotations.NullMarked; | ||
|
||
@NullMarked | ||
class UnsatisfiedTypeBounds { | ||
interface Foo<T extends Foo<T>> { | ||
T get(); | ||
} | ||
|
||
interface Command {} | ||
|
||
static class FooCommand implements Foo<FooCommand>, Command { | ||
@Override | ||
public FooCommand get() { | ||
return this; | ||
} | ||
} | ||
|
||
static final class Helper<T> {} | ||
|
||
// TODO(b/395578676): Uncomment when fixed. | ||
// static <T> T methodWithTypeConstraints(Helper<T> helper, Foo<? extends T> foo) { | ||
// return foo.get(); | ||
// } | ||
|
||
// static void test() { | ||
// Command command = methodWithTypeConstraints(new Helper<Command>(), new FooCommand()); | ||
// } | ||
} |
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
19 changes: 19 additions & 0 deletions
19
...readable/java/j2kt/output_kt/AnonymousClassUninitializedFieldReference+J2ObjCCompat.h.txt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Generated by J2KT from "j2kt/AnonymousClassUninitializedFieldReference.java" | ||
|
||
#import <Foundation/NSObjCRuntime.h> | ||
|
||
@class J2ktJ2ktAnonymousClassUninitializedFieldReference; | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@compatibility_alias J2ktAnonymousClassUninitializedFieldReference J2ktJ2ktAnonymousClassUninitializedFieldReference; | ||
|
||
NS_INLINE J2ktJ2ktAnonymousClassUninitializedFieldReference* create_J2ktAnonymousClassUninitializedFieldReference_initWithId_(id obj) { | ||
return [[J2ktJ2ktAnonymousClassUninitializedFieldReference alloc] initWithId:obj]; | ||
} | ||
|
||
NS_INLINE J2ktJ2ktAnonymousClassUninitializedFieldReference* new_J2ktAnonymousClassUninitializedFieldReference_initWithId_(id obj) { | ||
return [[J2ktJ2ktAnonymousClassUninitializedFieldReference alloc] initWithId:obj]; | ||
} | ||
|
||
NS_ASSUME_NONNULL_END |
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
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
Oops, something went wrong.