Skip to content

Fix local test failure in GenericsWrapJavaTests#588

Merged
ktoso merged 1 commit intoswiftlang:mainfrom
sidepelican:fix_optional_test_failure
Mar 6, 2026
Merged

Fix local test failure in GenericsWrapJavaTests#588
ktoso merged 1 commit intoswiftlang:mainfrom
sidepelican:fix_optional_test_failure

Conversation

@sidepelican
Copy link
Contributor

@sidepelican sidepelican commented Mar 6, 2026

On my local, test_wrapJava_genericMethodTypeErasure_ofNullableOptional_staticMethods fails, even though it appears to pass in CI. This suggests the failure might be environment-specific.

error: -[SwiftJavaToolLibTests.GenericsWrapJavaTests test_wrapJava_genericMethodTypeErasure_ofNullableOptional_staticMethods] : XCTAssertTrue failed - Expected chunk: 
@JavaStaticMethod
public func ofNullable<T: AnyJavaObject>(_ arg0: T?) -> Optional<T>! where ObjectType == Optional<T>
}
not found in:
// ---------------------------------------------------------------------------
// Auto-generated by Java-to-Swift wrapper generator.
import SwiftJava
import SwiftJavaJNICore

@JavaClass("com.example.Optional")
open class Optional<T: AnyJavaObject>: JavaObject {

}
extension JavaClass {
  /// Java method `ofNullable`.
  ///
  /// ### Java method signature
  /// ```java
  /// public static <T> com.example.Optional<T> com.example.Optional.ofNullable(T)
  /// ```
@JavaStaticMethod
  public func ofNullable<T: AnyJavaObject>(_ arg0: T?) -> Optional<T>! where ObjectType == Optional<T>

  /// Java method `nonNull`.
  ///
  /// ### Java method signature
  /// ```java
  /// public static <T> T com.example.Optional.nonNull(T)
  /// ```
@JavaStaticMethod(typeErasedResult: "T!")
  public func nonNull<T: AnyJavaObject>(_ arg0: T?) -> T! where ObjectType == Optional<T>
}

In my research, the presence of the closing brace } seems to be the cause of the mismatch.
While the exact reason for this discrepancy across environments is unclear, but the brace is not critical to the intent of this test.
Therefore, I want to delete this.

@sidepelican sidepelican requested a review from ktoso as a code owner March 6, 2026 02:06
@ktoso
Copy link
Collaborator

ktoso commented Mar 6, 2026

Happy to take this

@sidepelican
Copy link
Contributor Author

I've been ignoring this every time. Thanks for accpeting.

@ktoso ktoso merged commit bfeabba into swiftlang:main Mar 6, 2026
61 checks passed
@sidepelican sidepelican deleted the fix_optional_test_failure branch March 6, 2026 02:31
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

Successfully merging this pull request may close these issues.

2 participants