Skip to content

Use Java generic type parameters constraints #669

@jonpryor

Description

@jonpryor

generator doesn't "forward" and use generic type constraints in bindings. Consider this Java type:

package com.xamarin.android;

public interface InvokeRunnable<T extends Runnable> {
    void invoke (T runnable);
}

Here, T is contained to be a type that implements java.lang.Runnable.

However, the binding that generator emits is:

	[Register ("com/xamarin/android/InvokeRunnable", "", "Com.Xamarin.Android.IInvokeRunnableInvoker")]
	[global::Java.Interop.JavaTypeParameters (new string [] {"T extends java.lang.Runnable"})]
	public partial interface IInvokeRunnable : IJavaObject, IJavaPeerable {

		// Metadata.xml XPath method reference: path="/api/package[@name='com.xamarin.android']/interface[@name='InvokeRunnable']/method[@name='invoke' and count(parameter)=1 and parameter[1][@type='T']]"
		[Register ("invoke", "(Ljava/lang/Runnable;)V", "GetInvoke_Ljava_lang_Runnable_Handler:Com.Xamarin.Android.IInvokeRunnableInvoker, Xamarin.Android.McwGen-Tests")]
		void Invoke (global::Java.Lang.Object p0);

	}

The Java-side parameter, which must be a java.lang.Runnable or type implementing that interface, is bound as Java.Lang.Object.

Feature request: "forward" this constraint information, and use it in the binding, so that we instead emit:

	public partial interface IInvokeRunnable : IJavaObject, IJavaPeerable {

		[Register ("invoke", "(Ljava/lang/Runnable;)V", "GetInvoke_Ljava_lang_Runnable_Handler:Com.Xamarin.Android.IInvokeRunnableInvoker, Xamarin.Android.McwGen-Tests")]
		void Invoke (global::Java.Lang.IRunnable p0);
	}

Metadata

Metadata

Assignees

No one assigned

    Labels

    generatorIssues binding a Java library (generator, class-parse, etc.)

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy